Maximum Twin Drone Harvest
Preview mode. Log in to edit, run, submit, and save progress.
Maximum Twin Drone Harvest
An automated warehouse stores energy cells in a rectangular field. The value field[i][j] is the amount of energy available at row i and column j. Two harvest drones start on the first row: one at column 0 and the other at column cols - 1. On every move, both drones must go to the next row. From column c, a drone may move to column c - 1, c, or c + 1, as long as it stays inside the field. When a drone lands on a cell, it collects all energy from that cell. If both drones land on the same cell during a row, that cell's energy is counted only once. Both drones must make exactly one move per row until they reach the bottom row. Return the maximum total energy the two drones can collect.
Examples
field = [[4,1,2,5],[3,6,1,2],[1,4,8,3],[2,7,1,6]]
42
Explanation: The drones can coordinate their paths so the combined harvest over all four rows is 42.
Approach hint
Both drones are always on the same row, so the row index can be shared.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.