You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries you can collect from cell (i, j). Two robots are located at (0, 0) and (0, cols-1). Return the maximum number of cherries collected using both robots by moving towards the bottom.
30:00
Java
Cherry Pickup II
hard
Topics
Companies
You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries you can collect from cell (i, j). Two robots are located at (0, 0) and (0, cols-1). Return the maximum number of cherries collected using both robots by moving towards the bottom.
Example 1:
Input: {"grid":[[3,1,1],[2,5,1],[1,5,5],[2,1,1]]}
Output: 24
Constraints:
rows==grid.length
cols==grid[i].length
2≤rows,cols≤70
0≤grid[i][j]≤100
Input
arr ={"grid":[[3,1,1],[2,5,1],[1,5,5],[2,1,1]]}
Grid is 4 by 3. Robot 1 starts at (0,0), robot 2 at (0,2).