6
votes
Accepted
Is 'call site' compiler generated auto code?
“Call site” refers to the place where a function or method is called. It is a common term in compiler construction, and not specific to C#.
foo(); // call site
void foo() { ... } // function ...
3
votes
Accepted
Merging algorithm for overlapping intervals
How does the dynamic array matter?
You'll still want to store the values in sorted ascending order. Then it should be a relatively straightforward binary search to find the closest intervals (based ...
3
votes
design problem handling a dynamic object
I prefer to validate in the constructor. The idea behind that is then you know that the object state is valid because the object exists.
Now maybe you can’t validate at the client for some reason. ...
3
votes
Algorithm – Number of strings containing every string of a given set a strings
Well, any of the strings from S that your target string has to contain must start at some index i < l, right? So
just start searching states of the world where the first string is at index 0, 1, 2 ...
3
votes
Optimal sequence of recipes
This problem can be modeled as a longest path search in a directed graph. Each vertex of the graph corresponds to a set of currently available resources (starting with the empty set), and the recipes ...
2
votes
Accepted
How should I apply dynamic programming on the following problem
This is a O(n^3) approach
The time complexity has to do with k as well. The DP should give you a O(nk) instead.
Similar with a knapsack problem, you can use a recursive way with memorization to ...
2
votes
What to memoize in Dynamic programming questions?
Memoization is an optimization, not a solution.
what to memoize isn’t that obvious
Write the solution first, and then memoize whatever you redundantly compute more than once. Trying to skip the ...
1
vote
Leetcode: 2327. Number of People Aware of a Secret and Problem with programming skill in general
I'm trying to provide an intuitive answer to your intuitive question here, because you're not asking how to solve the problem but rather why recursion is not the favored way of doing so.
Let's explore ...
1
vote
Leetcode: 2327. Number of People Aware of a Secret and Problem with programming skill in general
There are a number of skills/techniques/experiance that will help with Leetcode style problems, specifically:
Being able to switch between imperative and functional (recursive) forms - sometimes one ...
1
vote
Leetcode: 2327. Number of People Aware of a Secret and Problem with programming skill in general
It sounds like you're not happy with the solutions you're coming up with. Even when they work they aren't fast enough to make you happy. Keep demanding perfection and you're sure to maintain your ...
1
vote
Accepted
Given n points in Cartesian 2D coords and only able to move directly from point to point how can you reach any point while minimising the longest jump
So input of your algorithm is "O" as starting point, "T" as the target point, and a set of intermediate points. I would try the following approach:
Create the list of all segments ...
1
vote
Algorithm – Number of strings containing every string of a given set a strings
I don't see an easy way to efficiently do this. The closest I've come is the following (works for Python 3.9):
from typing import Optional
Template = list[Optional[str]]
def possible_match(...
1
vote
Calling recursive method in a loop - Backtracking
For Partition Sum Equal to K, The loop in Sol 1 means you randomly choose indices from [index, n-1] in each recursion, and loop in Sol 2 means you either choose or not choose the next index (index + 1)...
1
vote
Is 'call site' compiler generated auto code?
The most typical use of call-site is probably that as presently declared on Wikipedia: it is nothing more than the place in some code where a call to a function or subroutine is made. It is a ...
1
vote
Find path of steepest descent along with path length in a matrix
I solved it using a memoized DFS solution. I am visualizing this matrix as a DAG with the values as nodes and a edge to NWES neighbors only if the value of the neighbor is < the value at the node. ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
dynamic-programming × 68algorithms × 47
java × 5
c++ × 5
optimization × 5
strings × 4
recursion × 4
array × 3
computer-science × 3
graph × 3
c# × 2
python × 2
data-structures × 2
complexity × 2
problem-solving × 2
combinatorics × 2
design-patterns × 1
object-oriented × 1
php × 1
unit-testing × 1
c × 1
compiler × 1
memory × 1
self-improvement × 1
sorting × 1