FastPrepCount Disappearing Connected Tiles
Problems/Count Disappearing Connected Tiles

Count Disappearing Connected Tiles

Indeed logoIndeed● MediumFULLTIMEPHONE SCREEN

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported disappearing-tile task matches at about 98%; all ten literal source cases and the explicit no-diagonal rule are retained. Board dimensions and valid selection bounds are practice assumptions.

A player selects the tile at [row,col] in a rectangular integer grid. The selected tile disappears, together with every same-valued tile you can reach from it by moving up, down, left or right through same-valued tiles. Tiles are not connected diagonally.

Return how many tiles disappear, including the selected tile. Other components with the same number are not counted; tiles with different values stop connectivity.

For this exercise, assume a nonempty equal-width board with 1 to 30 rows and columns, integer digits 0 through 9, and a valid zero-based selection.

Function

disappear(grid: int[][], row: int, col: int) → int

Examples

Example 1

grid = [[4,4,4,4],[5,5,5,4],[2,5,7,5]]row = 0col = 0return = 5
grid
0123044441555422575

This exact source testcase removes 5 equal-valued tiles from the selected four-neighbor component.

Example 2

grid = [[4,4,4,4],[5,5,5,4],[2,5,7,5]]row = 1col = 1return = 4
grid
0123044441555422575

This exact source testcase removes 4 equal-valued tiles from the selected four-neighbor component.

Example 3

grid = [[4,4,4,4],[5,5,5,4],[2,5,7,5]]row = 1col = 0return = 4
grid
0123044441555422575

This exact source testcase removes 4 equal-valued tiles from the selected four-neighbor component.

Example 4

grid = [[0,3,3,3,3,3,3],[0,1,1,1,1,1,3],[0,2,2,0,2,1,4],[0,1,2,2,2,1,3],[0,1,1,1,1,1,3],[0,0,0,0,0,0,0]]row = 0col = 0return = 12
grid
0123456003333331011111320220214301222134011111350000000

This exact source testcase removes 12 equal-valued tiles from the selected four-neighbor component.

Example 5

grid = [[0,3,3,3,3,3,3],[0,1,1,1,1,1,3],[0,2,2,0,2,1,4],[0,1,2,2,2,1,3],[0,1,1,1,1,1,3],[0,0,0,0,0,0,0]]row = 3col = 0return = 12
grid
0123456003333331011111320220214301222134011111350000000

This exact source testcase removes 12 equal-valued tiles from the selected four-neighbor component.

Example 6

grid = [[0,3,3,3,3,3,3],[0,1,1,1,1,1,3],[0,2,2,0,2,1,4],[0,1,2,2,2,1,3],[0,1,1,1,1,1,3],[0,0,0,0,0,0,0]]row = 1col = 1return = 13
grid
0123456003333331011111320220214301222134011111350000000

This exact source testcase removes 13 equal-valued tiles from the selected four-neighbor component.

Example 7

grid = [[0,3,3,3,3,3,3],[0,1,1,1,1,1,3],[0,2,2,0,2,1,4],[0,1,2,2,2,1,3],[0,1,1,1,1,1,3],[0,0,0,0,0,0,0]]row = 2col = 2return = 6
grid
0123456003333331011111320220214301222134011111350000000

This exact source testcase removes 6 equal-valued tiles from the selected four-neighbor component.

Example 8

grid = [[0,3,3,3,3,3,3],[0,1,1,1,1,1,3],[0,2,2,0,2,1,4],[0,1,2,2,2,1,3],[0,1,1,1,1,1,3],[0,0,0,0,0,0,0]]row = 0col = 3return = 7
grid
0123456003333331011111320220214301222134011111350000000

This exact source testcase removes 7 equal-valued tiles from the selected four-neighbor component.

Example 9

grid = [[0]]row = 0col = 0return = 1
grid
000

This exact source testcase removes 1 equal-valued tiles from the selected four-neighbor component.

Example 10

grid = [[1,1,1],[1,1,1],[1,1,1]]row = 0col = 0return = 9
grid
012011111112111

This exact source testcase removes 9 equal-valued tiles from the selected four-neighbor component.

Constraints

  • For this exercise, assume 1 <= grid.length, grid[0].length <=30 and every row has the same length.
  • 0 <= grid[r][c] <=9.
  • 0 <= row < grid.length and 0 <= col < grid[0].length.

More Indeed Phone Screen questions

  • Insert into an Unrolled Linked ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Course Completion OrderPHONE SCREEN · Seen May 2025
  • Recipes You Can PreparePHONE SCREEN · Seen May 2025
  • Rotting Orange PropagationPHONE SCREEN · Seen May 2025
  • Courses Shared by Every Student PairPHONE SCREEN · Seen Aug 2022
  • First and Last Access Time per UserPHONE SCREEN · Seen Jul 2022
  • Most Accessed Resource in Five MinutesPHONE SCREEN · Seen Jul 2022
  • Resource Transition GraphPHONE SCREEN · Seen Jul 2022
  • First Dictionary Word from Note LettersPHONE SCREEN · Seen Jul 2022
  • Word Path Moving Only Right or DownPHONE SCREEN · Seen Jul 2022

Similar questions at other companies

  • Matrix EscapeByteDance · PHONE SCREENByteDance interview questions
  • Minimum Time to Spread Through a GridAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Max Area of Island Without Changing the GridFlexport · PHONE SCREENFlexport interview questions
  • Reachable Exits in an Obstacle GridWhatNot · PHONE SCREENWhatNot interview questions
  • Process Minesweeper Game OperationsAmperity · PHONE SCREENAmperity interview questions
  • Count Islands in a Binary GridApple · PHONE SCREENApple interview questions
  • Find and Reconstruct a Binary-Matrix PathMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Pacific Atlantic Water FlowAnduril · PHONE SCREENAnduril interview questions
  • Fuel-Aware Grid ReachabilityBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • House Bounds in a Ragged GridRippling · OA · PHONE SCREENRippling interview questions

Indeed interview experiences

  • Indeed Experienced SWE Karat Screens and OAs: 6 Experiences
  • Indeed SWE Intern Karat Screens and OA: 3 Experiences
  • Indeed New Grad SWE Online Assessments: 3 Experiences
All Indeed interview questionsSee Indeed hiring insights
Saved
class Solution {
    public int disappear(int[][] grid, int row, int col) {
        // Write your code here.
        return 0;
    }
}
Checking account…