PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Other / Miscellaneous/Pinterest

Implement tap-to-infect color grid on iOS

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in mobile UI architecture, grid data structures, connected-component algorithm reasoning, and state management concerns such as undo and memory/stack safety within the mobile app development and iOS domain.

  • medium
  • Pinterest
  • Other / Miscellaneous
  • Software Engineer

Implement tap-to-infect color grid on iOS

Company: Pinterest

Role: Software Engineer

Category: Other / Miscellaneous

Difficulty: medium

Interview Round: Onsite

Implement an iOS app that displays a 2D grid of cells colored with two colors. When the user taps a cell, all 4-directionally adjacent cells of the same original color should be "infected" and change to the tapped color in a single interaction. Describe your UI architecture (UIKit or SwiftUI), data structures to represent the grid, and the flood-fill algorithm (iterative vs. recursive) with time/space complexity. Handle large grids efficiently, avoid stack overflow, and support reset/undo.

Quick Answer: This question evaluates proficiency in mobile UI architecture, grid data structures, connected-component algorithm reasoning, and state management concerns such as undo and memory/stack safety within the mobile app development and iOS domain.

Related Interview Questions

  • Build an emoji blaster animation on iOS - Pinterest (medium)
Pinterest logo
Pinterest
Sep 6, 2025, 12:00 AM
Software Engineer
Onsite
Other / Miscellaneous
11
0

iOS Grid Infection (Flood Fill) Design

Goal

Build an iOS app that displays a 2D grid with two colors. When the user taps a cell, all 4-directionally adjacent cells in the same connected component as the tapped cell should be flood-filled in a single interaction.

Assumptions (to make the problem well-scoped)

  • The grid contains exactly two colors (e.g., Color A and Color B).
  • On tap at cell (r, c), we flood-fill the connected component of the tapped cell’s original color to the other color (toggle). Alternatively, if a current paint color is selected in UI, fill to that color; the algorithm and design remain the same.
  • Adjacency is 4-directional (up, down, left, right).
  • The app should handle large grids efficiently, avoid stack overflow, and support reset and undo.

Deliverables

Describe:

  1. UI architecture (UIKit or SwiftUI) and view structure.
  2. Data structures to represent the grid.
  3. Flood-fill algorithm (iterative vs. recursive) with time/space complexity.
  4. How to handle large grids efficiently and avoid stack overflow.
  5. How to support reset and undo.

Solution

Show

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Other / Miscellaneous•More Pinterest•More Software Engineer•Pinterest Software Engineer•Pinterest Other / Miscellaneous•Software Engineer Other / Miscellaneous
PracHub

Master your tech interviews with 8,000+ 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.