Cherry Pickup II

Given a rectangular integer matrix, two robots begin at its top-left and top-right cells. Each move takes each robot down one row and changes its column by…

Given a rectangular integer matrix, two robots begin at its top-left and top-right cells. Each move takes each robot down one row and changes its column by -1, 0 or 1 without leaving the board. Both robots must reach the bottom row. Collect the cherries in each occupied cell, counting a cell only once when both robots occupy it in the same row. Return the maximum combined total. Return a scalar total, not robot paths; do not modify the matrix.

- 2 <= matrix.length <= 70; 2 <= matrix[0].length <= 70. - The board is rectangular; every cell is an integer in 0..1000. - Robots may meet, cross or separate. Shared occupancy counts the cell once. - The visualizer supports at most 4 rows and 4 columns; full bounds remain available for coding.

Example 1: input matrix = [[1,1],[5,0]]; output 7. The first row gives 2. Both robots may meet at the bottom-left cell, but its 5 cherries count once, not twice.

Example 2: input matrix = [[0,0,0],[0,10,0],[9,0,9]]; output 28. Both robots move to the middle 10, counted once, then separate to collect both bottom 9s.

Example 3: input matrix = [[0,0],[0,0]]; output 0. Both robots reach the last row. Zero is a completed maximum, not a missing route.

Category: Arrays. Topic: dynamic-programming. Difficulty: medium. Patterns: dynamic-programming.