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 Missing Orbit

Learn
Play
Prove
Problem context and objectives
Mission briefing

Puzzle systems engineer · A game mechanic is behaving incorrectly

Cancel indices against values: The Missing Orbit.

Brute force may pass the demo but fail when the world fills with players.

How you win

  1. 1Recognize when Missing number XOR matches the clues
  2. 2Keep this true after every move: the accumulator is the XOR difference between processed indices and values
  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: the accumulator is the XOR difference between processed indices and values
Lesson 1 of 3

Live algorithm trace

Missing number XOR

Complete execution
1 of 5

Seed answer with range endpoint 3.

1answer = array length
2for each index and value
3answer XOR= index
4answer XOR= value
5return answer
range = 0..3answer = 3
Truth to preserve / Cost target
Truth to preserve

the accumulator is the XOR difference between processed indices and values

Cost target

O(n) time and O(1) space

XOR every complete-range index and every present value. All shared numbers cancel, leaving the one range member absent from the array.

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