Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings

The Quiet Vaults

Learn
Play
Prove
Problem context and objectives
Mission briefing

Energy-route planner · A runner crosses a line of power stations

Build each decision from smaller outcomes already solved: The Quiet Vaults.

Re-solving the same future branches drains exponential energy.

How you win

  1. 1Recognize when House robber matches the clues
  2. 2Keep this true after every move: oneBack is the maximum reward from the processed prefix
  3. 3Reach the result within O(n) time and O(1) space

Rules and pressure

  • Target cost: O(n) time and O(1) space
  • State rule: oneBack is the maximum reward from the processed prefix
Lesson 1 of 3

Live algorithm trace

House robber

Complete execution
1 of 6

Start with no selected vaults and reward zero.

1twoBack = oneBack = 0
2for each reward
3take = twoBack + reward
4skip = oneBack
5current = max(take, skip); shift
6return oneBack
twoBack = 0oneBack = 0
Truth to preserve / Cost target
Truth to preserve

oneBack is the maximum reward from the processed prefix

Cost target

O(n) time and O(1) space

For each vault, either skip it and keep the previous best, or take it after the best prefix ending two positions earlier.

Your call · What should guide every step of this algorithm?

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead