Skip to content
Preptima

Dynamic Programming interview questions

Dynamic programming interview questions on state definition, recurrence transitions, memoisation, tabulation and recognising overlapping subproblems.

6 questions in Data Structures & Algorithms.

medium3

mediumCodingConcept

Edit distance where insert costs 1, delete costs 2 and replace costs 3. Define the DP state and the recurrence, and tell me what changes from the classic version.

The state is unchanged - the minimum cost to transform the first i characters of one string into the first j of the other - because the subproblem structure does not depend on what operations cost. Only the recurrence changes, adding a per-operation weight instead of a uniform 1, and the base cases become multiples of the insert and delete costs rather than i and j.

4 minmid, senior
mediumCodingConcept

How do you know a problem is dynamic programming?

Dynamic programming interview questions usually need overlapping subproblems, optimal substructure and a precise state definition. Define the minimum state, write the transition, then choose memoisation or tabulation based on dependency order.

5 minmid, senior

hard3