Back to DSA sheet
Grid Game
MediumArraysA 2xN grid of points. Two robots travel from top-left to bottom-right, moving only right or down (one move down each). The first robot collects points and zeros out its path; the second robot then takes the best remaining path. The first robot wants to minimise the second robot's best score, the second wants to maximise it. Return the second robot's score under optimal play.
Input format (stdin): the first line has n. The next two lines each have n integers (the two rows). Output the resulting score.
Examples
Input: 3
2 5 4
1 5 1
Output: 4
The first robot drops down to minimise what the second can take.
Constraints
- 1 <= n <= 5*10^4
- 0 <= grid[i][j] <= 10^5
Sheets
NeetCode 250
grid-game.cpp3 sample tests
Loading editor
Test results
Run the sample tests to check your solution against expected output.
Custom input (stdin)
Output
Run your code to see its output.