Google L4 round 1 question

Anonymous User
1941
May 05, 2025
May 05, 2025

The question was :

We are given a 2D grid (matrix) where each cell contains a height (positive integer). This grid represents an island's heightmap.

Rules:

Rainfall starts at any cell.
Water can only flow downhill to orthogonal neighbors (up, down, left, right) that are strictly lower in height.
There is no diagonal movement.
Each cell's rainfall will ultimately reach a "destination" – a point where no further downhill movement is possible.

Objective: For every cell, determine the final destination point where rainfall stops.

follow up :

assume the flow can be any were and not only in one direction , so multiple lower points can have multiple basins

Ps - The interviwer was very much not respondent and was like he had no interest in the interview. I had to basically talk all throught the interview so that my confidence was not hampered.

Comments (8)