PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Uber

Simulate one-round color elimination on a grid

Last updated: Mar 29, 2026

Quick Overview

This question evaluates array and matrix manipulation skills, including grid traversal, orthogonal neighbor-checking, simultaneous state-update detection, and maintaining relative order while applying gravity-like column operations.

  • Medium
  • Uber
  • Coding & Algorithms
  • Software Engineer

Simulate one-round color elimination on a grid

Company: Uber

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Take-home Project

Given an m x n integer matrix board where board[r][c] > 0 represents a color and 0 represents empty: ( 1) A nonzero cell at (r,c) explodes in this round if at least two of its four orthogonal neighbors (up, down, left, right), within bounds, have the same color value as board[r][c]. ( 2) Determine all exploding cells simultaneously based on the initial board for this round; set them to 0. ( 3) Then apply gravity: in each column, slide all nonzero values down to the bottom, preserving their relative order, and fill the remaining cells at the top with 0s. Return the matrix after exactly one such round (detect explosions once, remove, then gravity). Implement the function and analyze time and space complexity.

Quick Answer: This question evaluates array and matrix manipulation skills, including grid traversal, orthogonal neighbor-checking, simultaneous state-update detection, and maintaining relative order while applying gravity-like column operations.

Related Interview Questions

  • Implement stream queries and bounded-difference subarrays - Uber (medium)
  • Implement Minesweeper and Word Search - Uber (medium)
  • Implement Store Autocomplete - Uber (medium)
  • Simulate a Rank-Based Tournament - Uber (medium)
  • Implement Cache Eviction And Seat Assignment - Uber (medium)
Uber logo
Uber
Sep 6, 2025, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
8
0

Given an m x n integer matrix board where board[r][c] > 0 represents a color and 0 represents empty: (

  1. A nonzero cell at (r,c) explodes in this round if at least two of its four orthogonal neighbors (up, down, left, right), within bounds, have the same color value as board[r][c]. (
  2. Determine all exploding cells simultaneously based on the initial board for this round; set them to 0. (
  3. Then apply gravity: in each column, slide all nonzero values down to the bottom, preserving their relative order, and fill the remaining cells at the top with 0s. Return the matrix after exactly one such round (detect explosions once, remove, then gravity). Implement the function and analyze time and space complexity.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Uber•More Software Engineer•Uber Software Engineer•Uber Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

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