← All problemsSign in

Hard Sequence

CodeChefRating 1278Open on judge ↗

Chef decided to write an infinite sequence. Initially, he wrote $0$, and then he started repeating the following process: - Look at the last element written so far (the $l$-th element if the sequence has length $l$ so far); let's denote it by $x$. - If $x$ does not occur anywhere earlier in the sequence, the next element in the sequence is $0$. - Otherwise, look at the previous occurrence of $x

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start