How do you recognize a dynamic programming problem?hard
Answer
Look for overlapping subproblems and an optimal answer that can be built from smaller answers.
Explanation
DP is useful when recursion repeats the same work. Define the state, recurrence, base cases, and fill order. Interviews often start with a brute-force recursion before adding memoization.
Follow-upWhat is the difference between memoization and tabulation?