Double Domino
Cody and his friend are about to play a domino game. The board has two rows, each with N dominoes lined up. The two rows have exactly the same arrangement, and the height of the i-th domino from the left is denoted by hi.
They each take a different row and knock down dominoes from opposite ends.