Also called Coin-row problem and Most money with no two neighbours, by dynamic programming.
fresh numbers
The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from coin row's own run on the numbers shown.
choose one
1question 1
How many comparisons does the method make on the row 9, 8, 9, 1, 8?
the answer, and why
the answer is D
4 to fill, one for each coin from the 2nd. Then the walk back makes 3, one for each coin it decides on, taking coins 5, 3, 1.
if you chose another
AThat is filling alone; the walk back compares too.
BThat is one for each coin, but filling skips coin 1 and the walk skips the coin before each one it takes.
CThat counts the walk visiting every coin, but each take skips the coin before it.