Compute max island with constrained flips
Company: Dropbox
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Overview: This question evaluates understanding of grid-based graph connectivity, connected-component labeling, and algorithmic complexity analysis (time and space) within the Coding & Algorithms domain, emphasizing practical algorithm design for large-scale inputs.
Read the full Dropbox Data Scientist interview experience this question came from
Constraints
- grid is n by n and contains 0/1
Examples
Input: ([[1, 0], [0, 1]],)
Expected Output: 3
Explanation: Flip connects two diagonal islands through one cell only to adjacent land.
Input: ([[1, 1], [1, 1]],)
Expected Output: 4
Explanation: All land.
Hints
- Label each island and size, then evaluate each zero by unique neighboring island ids.