Fewest passes to collect a permutation in order
A shelf holds a permutation of 1..n. Starting with target 1, you scan the shelf left to right, and whenever you see the current target you take it and look for the next number. When you reach the end you start another pass. Return how many passes it takes to collect every number, in O(n).
No answer yet. Write the first one; the best answer gets endorsed.
