← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Junior

Junior
Jul 2026

Summary

Phone screen for a software engineering intern role at Google with two back-to-back coding problems. Pretty standard algo stuff but the second question tripped me up more than I expected.

Questions Asked (2)

Q1

Given an m x n grid where '1' represents land and '0' represents water, count the number of islands. Islands are formed by horizontally or vertically connected land cells, and the grid edges are all surrounded by water.

Algorithms & Data Structures
Author's notes

Classic BFS/DFS problem and I knew it the second I read it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Treat the grid as a graph and use DFS or BFS to explore each unvisited land cell, marking all connected land as visited to count one island. Iterate through every cell, incrementing the island count each time you start a traversal from an unvisited '1'.

Pro tip: Mention that you can optimize space by mutating the grid in-place (e.g., changing '1' to '0') if allowed, but always clarify with the interviewer first. Also, discuss handling very large grids with BFS to avoid recursion depth limits.

1. Clarify and Confirm

Restate the problem to ensure understanding: count connected components of '1's using 4-directional adjacency. Ask about constraints (e.g., grid size, mutability) and edge cases (empty grid, all water).

2. Choose Traversal Method

Decide between DFS (recursive or iterative) and BFS. Explain trade-offs: DFS is simpler but may hit recursion limits; BFS uses a queue and is safer for large grids.

3. Design Algorithm

Iterate over each cell. When encountering an unvisited '1', increment island count and launch a traversal to mark all connected land cells as visited (e.g., set to '0' or use a visited matrix).

4. Analyze Complexity

State time complexity O(m*n) since each cell is visited once, and space complexity O(m*n) in worst case for recursion stack or queue, or O(1) if mutating grid in-place.

5. Test with Examples

Walk through a small example (e.g., 3x3 with one island) and edge cases (no islands, all land, single row/column) to verify correctness.

Key Points to Mention

  • Graph traversal (DFS/BFS) to find connected components
  • Visited tracking: either modify grid in-place or use auxiliary matrix
  • Time complexity O(m*n) and space complexity O(m*n) worst case
  • Handling edge cases: empty grid, all water, all land, large grids
  • Iterative BFS to avoid stack overflow for large inputs
  • Potential follow-up: number of distinct island shapes or largest island

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

Q2

Given an array of uppercase letters, count the number of ways to select letters from the array such that the selected letters can be rearranged to spell GOOGLE. Each index is treated as a distinct choice even if two indices hold the same character.

Algorithms & Data Structures
Author's notes

This one looked easy for about thirty seconds.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Recognize that the target word 'GOOGLE' has specific character counts: G:2, O:2, L:1, E:1. For each character, count its occurrences in the array, then multiply the combinations of choosing the required number of each character from its available count. Since indices are distinct, use binomial coefficients for each character and multiply them together.

Pro tip: Clarify that the order of selection doesn't matter and that each index is distinct, so we're counting combinations, not permutations. Also, mention that if any character count is insufficient, the answer is zero.

1. Understand the problem

Restate the problem: count subsets of indices whose characters can be rearranged to form 'GOOGLE'. Note that rearrangement means we only need the correct multiset of characters.

2. Determine required character counts

Count the frequency of each character in 'GOOGLE': G appears 2 times, O 2 times, L 1 time, E 1 time. All other characters are irrelevant.

3. Count available characters

Iterate through the given array and count how many times each of the required characters (G, O, L, E) appears.

4. Compute combinations for each character

For each required character, if the available count is less than the needed count, the answer is 0. Otherwise, compute the binomial coefficient C(available, needed) for that character.

5. Multiply and return

Multiply the binomial coefficients for all required characters to get the total number of ways. Return the product.

Key Points to Mention

  • Character frequency analysis of the target word 'GOOGLE'.
  • Use of binomial coefficients (combinations) to count selections.
  • Indices are distinct, so selecting different indices with the same character counts as different ways.
  • Multiplication principle for independent choices.
  • Edge cases: insufficient characters, empty array, or array with extra irrelevant characters.
  • Time complexity: O(n) to count frequencies, O(1) to compute combinations (since counts are small).

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