n cells each: lanes[r][c] is the number of coins in lane r, column c. You can only move right along your lane or down, from the top lane to the bottom one in the same column. Each runner starts at the leftmost cell of the top lane (0, 0) and finishes at the rightmost cell of the bottom lane (1, n - 1).
The first runner goes first and collects every coin on their path, leaving those cells empty. Then the second runner goes and collects whatever is left on their own path; the paths may overlap.
The first runner picks a path that leaves the second as little as possible, while the second picks a path that collects as much as possible. Return how many coins the second runner collects when both play their best.lanes=[[4, 1, 7], [2, 6, 3]] → 7
If the first runner switches to the bottom lane at column 1, what remains is 7 coins on the top right and 2 on the bottom left, so the second collects 7. Switching at column 0 or 2 would leave the second runner 8.
lanes=[[9], [9]] → 0
The first runner passes through both cells and takes everything, leaving nothing for the second.
nlanes=[[4, 1, 7], [2, 6, 3]]
7
Run checks the first 3 tests in your browser. Submit checks all 75 tests on the server, hidden ones included.