Google interview questions
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-06-06Added By Anonymous
Source: Link
Company: Google
Role: unknown
Interview Stage: Onsite
Location: unknown
Year: unknown
Original Post Content:
Recently came across Google coding round onsite:
1) Find number of lakes in Atlantic Pacific Ocean
Given row, col find the number of lakes for given row, col.
Matrix is represented by 1's and 0's. => 1 being land, 0 being water.
For land 1's, find the number of 0's covered by 1's.
Strategy:
1) Find land using DFS and keep track of land pixels.
2) For given row, col, if it's part of land then go for DFS on land and find the number of lakes by validating and visiting 0's present or not.
Note: Forgot to handle edge cases.
Verdict: NH