Google Logo

Google SDE Interview Guide

45+ Questions: Deep-dive into Coding, Systems, and the unique "Googliness" culture fit. All questions include detailed answers.

Coding & DSA (Focus on Advanced Data Structures)

1. Design and implement a LFU (Least Frequently Used) cache. Hard

Answer & Explanation

LFU Cache Design: LFU evicts the item that has been used the least frequently. If there's a tie in frequency, the least recently used among them is evicted.

Data Structures Required:

  1. Map<Key, Node>: Stores key-value pairs and links to the list node.
  2. Map<Frequency, DoublyLinkedList>: Stores lists of nodes, grouped by their access frequency.
  3. min_freq: Integer tracking the minimum frequency present in the cache.

Operation: On get(key) or put(key, value), the node's frequency increases. It must be moved from its current frequency list to the frequency + 1 list. If the old frequency list becomes empty and it was the min_freq, then min_freq is incremented. Eviction removes the tail of the min_freq list.

2. Given a binary search tree, find the $k$-th smallest element in it. Medium

Answer & Explanation

Optimal Technique: Inorder Traversal. An inorder traversal of a BST visits nodes in strictly increasing order. We can perform an iterative inorder traversal using a stack. We decrement a counter $k$ for every node visited. The moment $k$ reaches zero, we have found the element.

Complexity: Time Complexity: O(H + k), where H is the height of the tree. This is generally faster than O(N) if k is small. Follow-up: For frequent calls, augment the tree nodes with the count of nodes in their left subtree.

3. Given an array of integers, return a new array where each element is the product of all elements in the original array except the one at the current index. Solve without division in O(n). Medium

Answer & Explanation

Technique: Prefix and Suffix Product Arrays. We need two passes:

  1. First Pass (Prefix): Iterate forward. At index $i$, store the product of all elements to the left of $i$.
  2. Second Pass (Suffix): Iterate backward. Maintain a running product of elements to the right. Multiply this running suffix product by the pre-calculated prefix product already stored.

Example: For [1, 2, 3, 4], prefix array becomes [1, 1, 2, 6]. Suffix product starts at 1, then: $6\times1=6$; $2\times4=8$; $1\times(4\times3)=12$; $1\times(4\times3\times2)=24$. Final result: [24, 12, 8, 6].

System Design (G-Scale)

4. Design Google Maps: focus on scale, routing, and real-time updates. System Design

Answer & Explanation

Key Challenge: Achieving low-latency routing globally.

  • Data Storage: Road network data (nodes, edges) is stored in a distributed graph database. Geographic partitioning (Geo-hashing) is used for sharding.
  • Static Content: Map tiles are pre-rendered and served from a massive, multi-region CDN.
  • Real-time Traffic: Ingested from anonymous user GPS probes via low-latency stream processing (e.g., Kafka/F1). This data updates the weights on the graph edges, dynamically influencing the routing algorithm (A*/Dijkstra's with pre-computed shortcuts).
5. How would you design a distributed, highly available Load Balancer for a global microservice architecture? System Design

Answer & Explanation

High Availability: Use a two-tiered approach. **L4 (Network Level)** load balancing (like Maglev or equivalent Layer 4 IP forwarding) handles massive traffic volume, distributing requests based on IP/Port. **L7 (Application Level)** load balancing (HTTP headers, URL path) sits closer to the services, handling routing, SSL termination, and rate limiting.

Distribution: Use **consistent hashing** to map client requests to backend servers, minimizing cache invalidation when servers are added or removed.

Health Checks: Frequent, non-invasive health checks are crucial for quickly removing failed nodes from the distribution pool.

HR & Behavioral ('Googliness' Assessment)

6. Tell me about a time you had to challenge a manager or a senior colleague's decision, and the outcome. Behavioral

Answer & Explanation (STAR Method)

Focus: Demonstrating intellectual humility and data-driven courage.

S+T: The manager decided to cut the testing phase on a new API launch to meet a hard deadline (Task: ensure quality despite pressure).

A: You respectfully presented historical data showing that skipped testing had caused 10% more Sev 1 incidents. You proposed a compromise: launch with limited functionality (MVP) but maintain the necessary integration tests. You offered to work extra hours on the tests.

R: The manager agreed. The API launched on time, the core functionality was stable, and the full feature set followed one week later with zero bugs, preserving quality.

7. Describe a time you had to work on a project with vague or ambiguous requirements. How did you proceed? Behavioral

Answer & Explanation (STAR Method)

Focus: Dealing with ambiguity, proactivity, and communication.

S+T: You were tasked with "improving user login security" (too vague). (Task: define measurable goals).

A: You broke the project down. You scheduled quick 15-minute syncs with stakeholders (PM, Security) to identify key metrics (e.g., failed login attempts, successful MFA adoption rate). You defined a clear, minimal scope (MVP: MFA integration) and documented a "Decision Log" of assumptions made, sharing it with the team.

R: The documentation reduced confusion and allowed you to deliver the MVP efficiently, which was later expanded based on solid feedback, demonstrating comfort in ambiguity.

8. Why Google, and what technology outside of your core focus excites you most right now? HR Core

Answer & Explanation

Why Google: Link your desire to work there to their **scale, innovation, and global impact**. Mention specific products (e.g., Kubernetes, TensorFlow, Quantum Computing research) and how your skills (e.g., distributed systems) align with their DNA.

Tech Excitement: This tests curiosity (a key Googliness trait). Mention something cutting-edge but relevant to the industry, like **WebAssembly (WASM)** for enabling near-native speed in browsers, or **Homomorphic Encryption** for secure cloud computation. This shows breadth of knowledge.

View All 45+ Google Questions on the Search Page