Trains the technique from
LeetCode 1463Cherry Pickup IIThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A warehouse wall is a grid wall, where wall[r][c] is the number of parcels sitting in that cell.
Two arms clear the wall. Arm one starts at the top-left cell (0, 0) and arm two starts at the top-right cell (0, cols - 1), where cols is the number of columns.
(r, c) an arm may land on (r + 1, c - 1), (r + 1, c) or (r + 1, c + 1), and it must stay on the wall.Return the largest number of parcels the two arms can take between them.
Example 1
The starting cells give 1 and 2. On the only step the arms split the bottom row and take 3 and 4, for 10 parcels in all.
Example 2
The only parcels sit in the middle of the bottom row. Both arms can reach that cell, but a shared cell is emptied once, so the answer is 100.
Example 3
Arm one can only land on the first two columns of the bottom row and arm two on the last two. One arm reaches a loaded cell and the other cannot, so nine parcels come off the wall.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def cherry_pickup(wall: list[list[int]]) -> int:public int cherryPickup(int[][] wall)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.