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 Linked Rewards

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 Linked Rewards.

Re-solving the same future branches drains exponential energy.

How you win

  1. 1Recognize when Delete and earn matches the clues
  2. 2Keep this true after every move: the rolling best includes every decision through the current distinct value
  3. 3Reach the result within O(n + u log u)

Rules and pressure

  • Target cost: O(n + u log u)
  • State rule: the rolling best includes every decision through the current distinct value
Lesson 1 of 3

Live algorithm trace

Delete and earn

Complete execution
1 of 5

Aggregate three copies of value 3 into nine available points.

1sum points by value
2sort distinct values
3for each value
4if consecutive: compare take with skip
5if gap: safely add current points
6return best
buckets = 2:2,3:9,4:4
Truth to preserve / Cost target
Truth to preserve

the rolling best includes every decision through the current distinct value

Cost target

O(n + u log u)

Taking value x earns all copies of x but forbids x-1 and x+1. Aggregate points by numeric value, then run take-or-skip across the sorted value axis.

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