← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Uber SWE coding round, just one question about Minesweeper. Pretty straightforward on the surface but the 2D array printing part tripped me up a bit.

Questions Asked (1)

Q1

Implement a Minesweeper board: randomly place a set of mines on a 2D grid, then print the full grid.

Algorithms & Data Structures
Author's notes

Spent too long overthinking the random placement logic and not enough time on clean output formatting.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the requirements first: grid dimensions, number of mines, and whether the printed grid should show mine locations or counts. Then outline a solution that initializes the grid, randomly places mines without duplicates, and prints the grid in a readable format. Finally, discuss potential edge cases and optimizations.

Pro tip: Mention that you would use a Fisher-Yates shuffle or reservoir sampling to place mines uniformly at random without duplicates, and discuss how to scale the solution for large grids.

1. Clarify requirements

Ask about grid size, mine count, and whether the output should display mines as '*' and empty cells as '.' or include adjacent mine counts. Confirm if the grid is fixed or user-specified.

2. Design data structures

Choose a 2D array (list of lists) to represent the grid. Decide on a sentinel value for mines (e.g., -1) and initialize all cells to 0 or empty.

3. Place mines randomly

Use a random number generator to select unique positions for mines. Ensure no duplicates by using a set or by shuffling a list of all possible positions and taking the first N.

4. Print the grid

Iterate through the grid and print each cell according to the chosen representation (e.g., '*' for mines, '.' for empty). Format with spaces or separators for readability.

5. Discuss edge cases and optimizations

Consider cases like zero mines, all mines, or grid too small for mine count. Mention time/space complexity and potential optimizations for large grids.

Key Points to Mention

  • Uniform random placement of mines without duplicates
  • Choice of data structure (2D array vs. 1D array with index math)
  • Time and space complexity (O(rows*cols) for initialization and printing)
  • Edge cases: mine count exceeding grid size, zero mines, all mines
  • Readable output format and potential for adding adjacent mine counts
  • Scalability considerations for large grids (e.g., using bitsets or sparse representation)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.