Google | L5 | October 2024 | India
Hi Everyone,
I appeared for Google L5 interview in October 2024. Here are the questions I was asked. Hope this will help people preparing for the same role.
Round 1:
Straight from Leetcode : Meeting Rooms III
Round 2: Have seen this in some discuss section not a direct problem from leetcode. Similar to this - https://leetcode.com/discuss/interview-question/763001/count-number-of-freshwater-lakes-in-2d-matrix
However, the constraints were different.
1You are given a 2D grid grid of size m x n, where:
2
3Each cell contains a value of either 0 or 1.
40 represents water, which can either be saltwater (connected to the infinite ocean) or freshwater (completely surrounded by land).
51 represents land.
6The grid is implicitly surrounded by an infinite ocean of saltwater.
7You are also given a specific point [i, j] in the grid such that grid[i][j] == 1.
8This point represents a land cell within a specific piece of land.
9A piece of land is defined as a connected group of 1s (connected horizontally or vertically, but not diagonally).
10
11Your task is to determine the number of freshwater lakes within the piece of land that contains the cell [i, j].
12A freshwater lake is defined as a group of 0s that is completely enclosed by the land (i.e., not connected to the infinite ocean).
13
14Input:
15grid - A 2D integer array of size m x n (1 <= m, n <= 1000):
16grid[i][j] == 0 represents water.
17grid[i][j] == 1 represents land.
18[i, j] - A pair of integers representing a land cell's position in the grid, where grid[i][j] == 1.
19Output:
20An integer representing the number of freshwater lakes in the piece of land containing [i, j].
21
22Example:
23Input: grid = [
24 [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
25 [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
26 [0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
27 [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0],
28 [0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0],
29 [0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0],
30 [0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0],
31 [0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0]
32]
33point = [4, 4]
34Output: 2Round 3:
Again straight from leetcode: Smallest String With Swaps
Thanks to this community, I got a lot of new problems to work on. Trying to return a small favour.
Related topics :-
Job Resources
Learn programming languages
Resume templates for software developers
DevOps training
Talent Identification
Mock coding interviews
Mock Interviews
Computer programming forums