DocuSign·Software Engineer·Technical Phone Screen
- You're given an m×n grid where 0 is water and any nonzero value is land. Connected land cells (4-directional) form an island. Find the maximum sum of cell values across all islands.
- Now restrict valid islands to those where every cell has a non-negative value. Islands containing any negative cell are completely ignored. Recompute the maximum sum under this rule.
- For whichever island has the maximum sum, also return the index (row, column) of any one cell belonging to that island.
- Instead of any cell index, return specifically the last cell of the winning island in row-major order, meaning the lexicographically largest (r, c) pair by row first then column. If multiple islands tie on sum, break the tie by choosing the island whose last row-major cell is largest.
- Walk through your algorithm design for all the above variants and analyze the time and space complexity.
“Classic flood fill setup.”