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
- 1Recognize when Circular house robber matches the clues
- 2Keep this true after every move: each linear run returns the best nonadjacent reward inside its chosen range
- 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 execution1 of 4
Split the endpoint conflict into two complete linear cases.
1
if one vault, return it2
solve linear range without last3
solve linear range without first4
within each range compare take and skip5
return max of both range answerscircle = [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?