Deshaw | Baby Ninja: Dynamic Programming with Survival Constraints | July 2022

deshaw · Question · Posted Apr 2026

Problem Statement: Baby Ninja The Scenario: Baby Ninja Maku is visiting n consecutive "candy banks." Bank i: Contains ai​ candies. If ai​>0: She steals ai​ candies.If ai​<0: She loses ∣ai​∣ candies. Survival Rule: If at any moment her candy count drops below 0 after visiting a bank, she goes to jail and loses everything. Movement Rule: She can only move from index i to index i+k. Starting State: She starts with c candies (from her mom). Starting/Ending: She can start ...

The full answer & interview discussion are available to premium members.

Log in Create a free account