Google — Software Engineer ✅ Passed
Level: Unknown Level
Round: Full Journey · Type: Coding · Difficulty: 4/10 · Duration: 120 min · Interviewer: Neutral
Topics: Arrays, Queues, Graphs, Binary Trees, Graph Traversal
Location: Mountain View, CA
Interview date: 2026-01-20
Summary
Round 1: Coding
Question: Given an array and an offset, output the first 'offset' elements if the offset is positive, and the last 'offset' elements if negative. Follow-up: Handle the same problem when the array is a stream with hasNext() and getNext() functions.
Round 2: Coding
Question: Given an undirected acyclic graph, determine if it is a valid binary tree and output its root. Follow-up: Given each node has a color (black or white), check if there's a valid binary tree where each level has the same color.
Details
Round 1: Array and Stream Processing
The coding question involved manipulating an array based on a given offset. The follow-up required adapting the solution to handle an incoming stream of data using hasNext() and getNext() methods.
My Approach:
- For the array problem, I used array slicing based on whether the offset was positive or negative.
- For the stream follow-up, I used a queue to store the elements and maintain the required offset.
Key Insights:
- Using a queue is an efficient way to handle streaming data.
- Understanding the constraints of the problem is crucial for optimizing the solution.
Round 2: Graph and Binary Tree Validation
The coding question was to determine if a given undirected acyclic graph is a valid binary tree and, if so, to return its root. The follow-up added the constraint that each node has a color (black or white), and the task was to check if there's a valid binary tree where each level has the same color.
My Approach:
- I used graph traversal techniques to validate the structure.
- For the follow-up, I considered level-order traversal to check color consistency.
Key Insights:
- Thorough understanding of graph properties and traversal algorithms is essential.
- Considering all possible edge cases and constraints is crucial for solving the problem.
Preparation Tips & Key Takeaways
What I Learned
- Communicating my thought process clearly to the interviewer is crucial.
- The interviewer provided helpful guidance, making the problem-solving process easier.
Recommended Preparation
Coding Practice
- Practice array manipulation and stream processing problems.
- Review graph traversal algorithms.
Data Structures
- Understand the properties of queues, graphs, and trees.
Common Pitfalls to Avoid
- Not considering all edge cases.
- Failing to communicate your approach clearly.