Two-robot cherry collection
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]]) → intExamples
in
[[[3,1,1],[2,5,1],[1,5,5],[2,1,1]]]out24What 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.
0:00 of about 45 min
solution.py
InputExpectedGot
[[[3,1,1],[2,5,1],[1,5,5],[2,1,1]]]24not run yetsample