Google interviews software engineers with several rounds of coding and algorithm problems, system design for experienced roles, and a Googleyness and Leadership round, after which a hiring committee reviews the full packet. These Google interview questions cover the algorithm patterns Google favours, design questions and behavioural questions, with model answers and code.
19 questions · Updated
Reading answers is not the same as saying them.Practise Google questions out loud and get a score, what you missed and a model answer for each one.
Master problem-solving patterns, not individual problems: BFS and DFS, binary search (including on the answer), two pointers, sliding window, heaps, union-find, tries, topological sort and dynamic programming.
Practise writing clean code in a plain editor or on a whiteboard without autocomplete, since Google interviews often use a simple shared document.
Always discuss more than one approach, analyse time and space complexity, and handle follow-ups such as "What if the data does not fit in memory?"
For experienced roles, practise system design: scalability, sharding, caching, consistency and trade-offs, using examples such as a URL shortener, web crawler or autocomplete.
Prepare stories for Googleyness: handling ambiguity, collaborating across teams, giving and receiving feedback, and doing the right thing for users.
Coding round (DSA)
Data structures and algorithms problems solved live, usually in 45 minutes each. Explain your approach before you code.
1. Find the shortest transformation sequence from one word to another, changing one letter at a time (word ladder).
Answer flow · 3 steps
1
Model each word as a node with edges between words that differ by one letter, and use BFS from the start word, since BFS finds the shortest path in an unweighted graph.
2
To find neighbours quickly, try replacing each position with every letter a to z and check the word list stored in a set.
3
Time is roughly O(N × L × 26) for N words of length L.
from collections import deque
def ladder_length(begin, end, words):
words = set(words)
queue, seen = deque([(begin, 1)]), {begin}
while queue:
word, steps = queue.popleft()
if word == end:
return steps
for i in range(len(word)):
for c in "abcdefghijklmnopqrstuvwxyz":
nxt = word[:i] + c + word[i + 1:]
if nxt in words and nxt not in seen:
seen.add(nxt)
queue.append((nxt, steps + 1))
return 0
2. Given meeting time intervals, find the minimum number of meeting rooms needed.
Answer flow · 4 steps
1
Sort meetings by start time and keep a min-heap of end times for rooms in use.
2
For each meeting, if the earliest ending room is free (its end is at or before this start), reuse it by popping; then push this meeting's end.
3
The heap's size is the number of rooms needed.
4
Time is O(n log n).
import heapq
def min_rooms(intervals):
ends = []
for start, end in sorted(intervals):
if ends and ends[0] <= start:
heapq.heappop(ends) # reuse the room that freed up
heapq.heappush(ends, end)
return len(ends)
# min_rooms([[0, 30], [5, 10], [15, 20]]) -> 2
3. Can all courses be finished, given their prerequisites (course schedule)?
Answer flow · 4 steps
1
This asks whether a directed graph has a cycle.
2
Use Kahn's algorithm: count incoming edges for each course, start with courses that have none, and repeatedly remove them, reducing their neighbours' counts.
3
If every course is removed, there is no cycle and the removal order is a valid schedule.
4
Time is O(V + E).
from collections import deque, defaultdict
def can_finish(n, prereqs):
graph, indeg = defaultdict(list), [0] * n
for course, pre in prereqs:
graph[pre].append(course)
indeg[course] += 1
queue = deque(i for i in range(n) if indeg[i] == 0)
done = 0
while queue:
node = queue.popleft()
done += 1
for nxt in graph[node]:
indeg[nxt] -= 1
if indeg[nxt] == 0:
queue.append(nxt)
return done == n
4. Find the length of the longest increasing subsequence.
Answer flow · 4 steps
1
The O(n²) DP stores, for each index, the longest increasing subsequence ending there.
2
The O(n log n) approach keeps an array where tails[i] is the smallest possible tail of an increasing subsequence of length i + 1; for each number, binary search for its position and replace or append.
3
The array's length is the answer.
4
Google interviewers usually expect you to reach the faster version.
from bisect import bisect_left
def length_of_lis(nums):
tails = []
for x in nums:
i = bisect_left(tails, x)
if i == len(tails):
tails.append(x)
else:
tails[i] = x
return len(tails)
5. Return the maximum of every window of size k in an array (sliding window maximum).
Answer flow · 4 steps
1
Use a deque that stores indices in decreasing order of their values.
2
For each new element, pop smaller values from the back, since they can never be the maximum again, and pop the front if it has left the window.
3
The front is the current maximum.
4
Each index enters and leaves once, so the time is O(n).
6. What is the minimum eating speed to finish all piles of bananas within h hours?
Answer flow · 5 steps
1
This is binary search on the answer.
2
The speed lies between 1 and the largest pile.
3
For a candidate speed, the hours needed are the sum of ceil(pile / speed); if that is within h, try a slower speed, otherwise a faster one.
4
Time is O(n log m), where m is the largest pile.
5
Recognising "binary search on the answer" is a pattern Google tests often.
7. Count the number of connected components in an undirected graph.
Answer flow · 4 steps
1
Use union-find (disjoint set union).
2
Start with each node as its own component; for each edge, union the two nodes, and decrease the count when they were in different sets.
3
With path compression and union by rank, each operation is nearly O(1).
4
DFS also works, but union-find handles edges arriving one at a time, which is a common follow-up.
8. Implement a trie that supports insert, search and prefix search.
Answer flow · 3 steps
1
Each node holds a map of child characters and a flag marking the end of a word.
2
Insert walks down the characters, creating nodes as needed; search follows the characters and checks the end flag; startsWith only checks that the path exists.
3
Each operation is O(L) for a word of length L. Tries power autocomplete and spell checking.
System design and technical depth
Design questions and computer science fundamentals. Low-level design for freshers, high-level design for experienced engineers.
9. Design a search autocomplete (typeahead) system.
Answer flow · 4 steps
1
Requirements: suggest the top five completions as the user types, within about 100 ms, for billions of queries.
2
Store a trie (or a prefix-to-top-results table) built offline from query logs, with each node caching its top suggestions so lookups are O(prefix length).
3
Shard by prefix, cache popular prefixes at the edge, and rebuild or update the data periodically from aggregated logs.
4
Discuss filtering offensive suggestions and personalisation as extensions.
10. Design a web crawler.
Answer flow · 4 steps
1
Start from seed URLs in a URL frontier (a set of prioritised queues).
2
Workers fetch pages, respecting robots.txt and per-host politeness limits, extract links, normalise and deduplicate URLs (using a Bloom filter or a seen-URL store) and add new ones to the frontier.
3
Store page content and detect duplicate content with hashes.
4
Distribute work by hashing hostnames to workers, and handle traps such as infinite calendar pages with depth limits.
11. Design a rate limiter.
Answer flow · 3 steps
1
Common algorithms are token bucket (tokens refill at a fixed rate, and each request uses one, allowing short bursts), fixed window counters (simple, but allow bursts at window edges) and sliding window logs or counters (more accurate).
2
In a distributed system, keep counters in a shared store such as Redis with atomic increments or Lua scripts, and decide whether to fail open or closed if the store is down.
3
Return HTTP 429 with a Retry-After header.
12. What is consistent hashing, and why is it used?
Answer flow · 3 steps
1
Consistent hashing places both servers and keys on a hash ring; each key goes to the next server clockwise.
2
When a server is added or removed, only the keys between it and its neighbour move, instead of almost all keys as with hash mod N. Virtual nodes, where each server appears at many points on the ring, spread the load evenly.
3
It is used in distributed caches, databases such as Cassandra and DynamoDB, and load balancers.
13. How would you count YouTube video views accurately at a huge scale?
Answer flow · 4 steps
1
Writing every view directly to one database row would create a hot spot.
2
Instead, send view events to a log such as Kafka, aggregate them in stream processors in short windows, and write the totals to the database in batches.
3
Use sharded counters for very popular videos.
4
Filter bots and repeated views before counting, and accept that the displayed count may be slightly delayed (eventual consistency) in return for scale.
Googleyness and Leadership round
Questions about your past work and how you behave in a team. Answer with real stories using the STAR method.
14. Tell me about a time you worked on a project with unclear requirements.
Answer flow · 4 steps
1
Google values comfort with ambiguity.
2
For example: "Our professor asked for a tool to help students find study partners with no further detail.
3
I interviewed ten classmates, found the main need was matching by course and free time, built a simple version in two weeks and improved it based on feedback.
4
Eighty students used it in the first month." Show how you created clarity rather than waiting for it.
15. Tell me about a time you received critical feedback.
Answer flow · 3 steps
1
Show that you listened, did not get defensive and improved.
2
For example: "A senior reviewer said my pull requests were too large to review well.
3
I started breaking work into smaller changes with clear descriptions, and my review turnaround dropped from three days to one." Googleyness includes being open to feedback and learning from it.
16. Tell me about a time you helped a teammate succeed.
Answer flow · 4 steps
1
Pick an example where you invested in someone else.
2
For example: "A new teammate was struggling with our codebase.
3
I paired with her for an hour a day for a week, wrote a short guide to our architecture and reviewed her first pull requests in detail.
4
She shipped her first feature independently within a month, and the guide is now part of our on-boarding."
17. Tell me about a time you had to influence people without authority.
Answer flow · 4 steps
1
Show persuasion through data and empathy.
2
For example: "I wanted the team to adopt automated tests, but people saw them as slow.
3
I measured how many bugs reached production in a month, showed that most would have been caught by simple tests, and wrote tests for one module myself to demonstrate the effort was small.
4
The team agreed to require tests for new code."
18. Describe a time you made a decision that put users first, even though it was harder.
Answer flow · 3 steps
1
For example: "We were about to launch a feature that collected more location data than it needed.
2
I raised the privacy concern and proposed using city-level location instead.
3
It took an extra week, but users got the same value with less data collected." Google looks for people who do the right thing for users.
19. Tell me about a time you worked with a diverse team or someone with a very different perspective.
Answer flow · 4 steps
1
Show respect and inclusion.
2
For example: "In a hackathon our team had a designer, two developers and a business student.
3
Initially we developers dismissed the business student's ideas, but when we listened, his insight into what judges valued changed our pitch, and we won second place.
4
I learned to make space for every voice early."
Ready to test yourself?Pick your topics and level, answer by voice or text, and get instant feedback. Free.
Company names are trademarks of their respective owners. Interview Ready is an independent practice site and is not affiliated with or endorsed by any company listed here.