Google
More Experiences
Google L4 Phone Screen Round (US)
May 22, 2025 • 3 reads
Summary
I had a phone screen round for Google L4 in the US, where I solved a binary tree pathfinding problem, and I cleared the round.
Full Experience
Given 2 numbers and an unsorted binary tree, find the path between them and return it as a string with the words "up", "right" and "left"
1
/ \
2 7
/ \
8 6
/
5
Path(root, 6, 7) -> "up, up, right"
Path(root, 7, 8) -> "up, left, left"
Path(root, 5, 6) -> "up, up, left"
I asked the following questions:
- are the node values unique? Yes
- Will both nodes be always present in tree? Yes
Solved it using the following approach:
- Find LCA node between the two nodes.
- A path function that will record L/R from LCA node to first node.
- Same path function that will record L/R from LCA node to second node.
- Form the answer string a. place all "up" strings for path from LCA to start node b. append the recorded path from LCA to end node
Interviewer asked if I can optimise and decrease the traversals, as I was traversing the tree thrice. But couldn't think well in that interview setting.
EDIT: Cleared the phone screen round. Moving Onward
Interview Questions (1)
Q1
Find Path Between Two Nodes in Binary Tree
Data Structures & AlgorithmsMedium
Given 2 numbers and an unsorted binary tree, find the path between them and return it as a string with the words "up", "right" and "left"
1
/ \
2 7
/ \
8 6
/
5
Path(root, 6, 7) -> "up, up, right"
Path(root, 7, 8) -> "up, left, left"
Path(root, 5, 6) -> "up, up, left"
I asked the following questions:
- are the node values unique? Yes
- Will both nodes be always present in tree? Yes