PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Dropbox

Compute max island with constrained flips

Last updated: Mar 29, 2026

Quick 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.

  • Medium
  • Dropbox
  • Coding & Algorithms
  • Data Scientist

Compute max island with constrained flips

Company: Dropbox

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Given an n×n binary grid G where 1=land and 0=water with 4-directional connectivity, return the size of the largest island achievable by flipping at most one 0 to 1. n can be up to 10^3. Provide an O(n^2) time, O(n^2) or better space solution and justify correctness. Follow-ups: (a) If you must flip exactly one 1 to 0, what is the minimum number of islands you can achieve? Give an algorithm and complexity. (b) If you may perform one 0→1 flip and one 1→0 flip on distinct cells (in any order), compute the maximum possible largest-island size and prove optimality or provide a counterexample. Discuss edge cases (all 0s, all 1s), recursion-depth limits, and how you’d adapt for very large grids (e.g., chunking/streaming or union-find labeling).

Quick Answer: 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.

Related Interview Questions

  • Compute worst-case guesses for adaptive hangman - Dropbox (medium)
  • Return all files under a path - Dropbox (medium)
  • Build a hit/miss word guessing game - Dropbox (medium)
  • Implement feedback for word guessing game - Dropbox (medium)
  • Implement hierarchical folder access check - Dropbox (medium)
Dropbox logo
Dropbox
Oct 13, 2025, 9:49 PM
Data Scientist
Technical Screen
Coding & Algorithms
3
0

Given an n×n binary grid G where 1=land and 0=water with 4-directional connectivity, return the size of the largest island achievable by flipping at most one 0 to 1. n can be up to 10^3. Provide an O(n^2) time, O(n^2) or better space solution and justify correctness. Follow-ups: (a) If you must flip exactly one 1 to 0, what is the minimum number of islands you can achieve? Give an algorithm and complexity. (b) If you may perform one 0→1 flip and one 1→0 flip on distinct cells (in any order), compute the maximum possible largest-island size and prove optimality or provide a counterexample. Discuss edge cases (all 0s, all 1s), recursion-depth limits, and how you’d adapt for very large grids (e.g., chunking/streaming or union-find labeling).

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Dropbox•More Data Scientist•Dropbox Data Scientist•Dropbox Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.