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 Circular 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 Circular Vaults.

Re-solving the same future branches drains exponential energy.

How you win

  1. 1Recognize when Circular house robber matches the clues
  2. 2Keep this true after every move: each linear run returns the best nonadjacent reward inside its chosen range
  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: each linear run returns the best nonadjacent reward inside its chosen range
Lesson 1 of 3

Live algorithm trace

Circular house robber

Complete execution
1 of 4

Split the endpoint conflict into two complete linear cases.

1if one vault, return it
2solve linear range without last
3solve linear range without first
4within each range compare take and skip
5return max of both range answers
circle = [2,3,2]cases = [2,3] and [3,2]
Truth to preserve / Cost target
Truth to preserve

each linear run returns the best nonadjacent reward inside its chosen range

Cost target

O(n) time and O(1) space

The first and last vaults are adjacent. Any valid solution excludes at least one, so solve the two linear ranges that omit the first or omit the last.

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