Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
How can you find the minimum index such that all sequences of length 1 can be formed from the start until that index?
Starting from the previous minimum index, what is the next index such that all sequences of length 2 can be formed?
Can you extend the idea to sequences of length 3 and more?