Problem 1
The missing integer
A stream contains every integer from to exactly once, except for one missing value. The order is arbitrary.
Return the missing integer.
Model
The argument n gives , where . The stream contains integers. Each call to p1.next() consumes and returns the next integer. Consumed integers cannot be read again. Reading past the end stops execution.
int solve(int n)
int p1.next()- Consume and return the next integer in the stream.
Example
n = 6; stream = [0, 1, 3, 4, 5] Output: 2
Limits
- Time: 400,000 instructions
- Memory: 32 bytes