Google L4 round 1 question
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2025-05-05Added By Anonymous
Source: Link
The question was :
1We are given a 2D grid (matrix) where each cell contains a height (positive integer). This grid represents an island's heightmap.
2
3Rules:
4
5Rainfall starts at any cell.
6Water can only flow downhill to orthogonal neighbors (up, down, left, right) that are strictly lower in height.
7There is no diagonal movement.
8Each cell's rainfall will ultimately reach a "destination" – a point where no further downhill movement is possible.
9
10Objective: For every cell, determine the final destination point where rainfall stops.follow up :
1assume the flow can be any were and not only in one direction , so multiple lower points can have multiple basinsPs - 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.