Code Room
CodingHardcod-g752
Subject Grid dpLevel Senior–Staff~45 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Two robots start at the top row of an m x n grid: robot A at column 0, robot B at column n-1. Each step both robots move down one row, and each may shift to an adjacent column (left, straight, or right). When a robot lands on a cell it collects its cherries; if both land on the same cell, the cherries are only counted once. Return the maximum cherries collected by the time both reach the bottom row. Constraints: 1 <= m, n <= 70, 0 <= cell <= 100.

Implement
cherry_pickup_two(grid: list[list[int]]) → int
Examples
in[[[3,1,1],[2,5,1],[1,5,5],[2,1,1]]]out24
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.