2d dynamic Programming question

Asked atInfosys
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
  1. 01Ask for the exact input, output, constraints, and allowed moves/actions.
  2. 02Propose defining a 2D state only after the objective is known.
  3. 03Confirm base cases and transition dependencies.
  4. 04State that no correct implementation can be selected from the current prompt alone.

Reference answer

Then expect these follow-ups

  • Can you provide the inputs, objective, and permitted transitions?

    Tests: requirements gathering

  • How do you decide whether a problem needs 1D or 2D DP?

    Tests: state modeling

Hiring now

Get the Infosys interview, not just the prep

landed applies to roles like these for you, on each company’s own site, with answers written for the role.

Get 5x interviews10 free auto-applies. No card.
Or practice this question first

Next question