Make room for each new digit
Before the stream starts, read how many digits to report. Keep only that many of the most recent digits, in order. When another arrives, drop the oldest and add the new one at the end.
Suppose you are keeping three: 2, 5, 8. When 4 arrives, let 2 go and keep 5, 8, 4. The figures are snapshots to explain this update; the practice shows just one digit at a time.
Stop with the group you are holding
This short example stream is 8, 3, 6, 1, 9, then it stops. If asked for the last three, type 619. Those digits stay in the order you saw them, not newest first.
The practice does not reveal the stream length or count down to the end. Keep updating throughout. Lower levels ask for the last two digits, then later levels ask for three or four. Recall is untimed.
Keep the last two, in order
You were asked to report the last two digits. This example stream has now stopped. Which answer keeps those two in their original order?
Try it
The stream ends 8, 4, 7, 2, 6. What are the last two digits, in order?
- 62
- 26
Show the answer
26
Yes. Keep 2 and then 6. Report the newest two digits in the order they arrived.
Enable JavaScript to answer interactively and save your place.
Practice Running span