Google Interview Questions and Answers for SDE Roles
Last updated 2026-11-19
Google interviews are known for open-ended problem solving where how you think is assessed along with the answer. These questions cover the data-structure fundamentals Google's own prep material lists, a few scaling and testing prompts, and behavioural stories.
Each answer shows what a strong response sounds like, with code where it helps. They are practice in the style of the topics Google says it covers, not a record of past interviews.
| Coding format | Shared document, language of your choice |
|---|---|
| Topics Google lists | Trees, hash tables, stacks, arrays, linked lists, priority queues |
| Behavioural | Past-experience stories, STAR structure |
| Best paired with | Google coding round practice |
How the rounds are commonly reported for Indian SDE hiring
Google's public guidance describes live technical interviews in which you write code in a shared document, with reasoning valued as much as the final answer. Its older internship guide describes two 45-minute technical interviews, lets you choose a language such as C, C++, Go, Java, JavaScript or Python, and says pseudocode is generally not wanted. Several Google engineering postings state that most roles require in-person interviews at some stage, and its virtual-interview guide says using AI during the interview leads to disqualification.
Beyond that, details such as the number of loops, team matching and the exact mix of coding and design vary by role and year and are not published, so treat anything more specific as commonly reported rather than fixed.
- Expect to talk through the problem, state brute force first, then improve it.
- Topics Google itself lists include trees and tree traversal, hash tables, stacks, arrays, linked lists, priority queues and time and space trade-offs.
- Be ready to test your own code on small examples without running it.
What to practise for these questions
The questions below mix data-structure reasoning, a couple of design-by-conversation prompts and behavioural stories. For worked coding problems in the same style, use Google coding round questions, and for the process itself see how to crack the Google interview.
Hiring status
This is what Google has publicly said, with sources listed at the bottom. Google opened applications for a Software Engineering Intern, Summer 2027 role in India (Bengaluru, Hyderabad, Pune), with a reported deadline of 28 June 2026, so it has passed. It also opened India apprenticeship programmes starting March 2027, with a reported deadline of 3 August 2026, which have closed. Google began construction of its Visakhapatnam AI hub on 28 April 2026.
For current openings and dates, see Google hiring and apply only through Google's own careers site at google.com/about/careers/applications.
Google Interview Questions and Answers for SDE Roles: questions with worked answers
1 When does a hash table lookup stop being O(1), and how do you talk about it in an interview?
easyLookup is O(1) on average because a good hash function spreads keys across buckets and the table resizes to keep the load factor bounded. It degrades to O(n) when many keys collide, for example with a poor hash function, adversarial keys, or a table that never resizes. State both: average O(1), worst case O(n), and name the mitigation (resizing, better hashing, or tree buckets as in Java 8 HashMap, which makes worst case O(log n)). Interviewers value the caveat as much as the answer.
2 Hash map or balanced BST: how do you choose?
easyA hash map gives average O(1) insert, delete and lookup but no ordering. A balanced BST (TreeMap in Java, or a sorted container in Python) gives O(log n) operations and also supports ordered queries: smallest key, floor and ceiling, range scans and in-order iteration. If the problem asks 'the closest value not greater than x' or 'all keys between a and b', pick the tree. If it only asks 'have I seen this', pick the hash map.
3 Walk through an iterative in-order traversal of a binary tree and say what space it uses.
mediumKeep a stack. Walk left pushing nodes until you hit null, pop one, visit it, then move to its right child and repeat. Each node is pushed and popped once, so time is O(n). Space is O(h) for the stack, where h is the tree height: O(log n) for a balanced tree and O(n) for a skewed one. Mention Morris traversal as an O(1)-space alternative that temporarily rewires right pointers, and note it modifies the tree while running.
pythondef inorder(root): out, stack, cur = [], [], root while cur or stack: while cur: stack.append(cur) cur = cur.left cur = stack.pop() out.append(cur.val) cur = cur.right return outjavaimport java.util.*; class TreeNode { int val; TreeNode left, right; } class Solution { List<Integer> inorder(TreeNode root) { List<Integer> out = new ArrayList<>(); Deque<TreeNode> st = new ArrayDeque<>(); TreeNode cur = root; while (cur != null || !st.isEmpty()) { while (cur != null) { st.push(cur); cur = cur.left; } cur = st.pop(); out.add(cur.val); cur = cur.right; } return out; } }4 How would you track the k-th largest number in a stream?
mediumKeep a min-heap of size k. For each new number, push it, and if the heap grows beyond k, pop the smallest. The root is then the k-th largest. Each update costs O(log k) and space is O(k). A common mistake is using a max-heap of all elements, which costs O(n) space and O(log n) per update, or sorting after every insert, which is O(n log n) each time.
pythonimport heapq class KthLargest: def __init__(self, k, nums): self.k, self.h = k, [] for x in nums: self.add(x) def add(self, x): heapq.heappush(self.h, x) if len(self.h) > self.k: heapq.heappop(self.h) return self.h[0]javaimport java.util.*; class KthLargest { private final PriorityQueue<Integer> h = new PriorityQueue<>(); private final int k; KthLargest(int k, int[] nums) { this.k = k; for (int x : nums) add(x); } int add(int x) { h.offer(x); if (h.size() > k) h.poll(); return h.peek(); } }5 Find the ten most frequent search queries in a log file too large for memory.
hardStart by asking clarifying questions: how large, one machine or many, exact or approximate answer. For one machine, stream the file, hash each query into one of M partition files so equal queries land together, then for each partition count with a hash map and keep a size-10 min-heap of the best counts. Merge the heaps. With many machines, shard by hash of the query so counts never need merging. If approximate is fine, mention a count-min sketch plus a heap. Showing you scoped the problem first matters at Google.
6 Why is quicksort O(n log n) on average but O(n squared) in the worst case, and how do you avoid the worst case?
mediumEach partition step costs O(n). If the pivot splits the array roughly in half, the recursion depth is log n, giving O(n log n). If the pivot is always the smallest or largest element, as with a sorted array and a first-element pivot, the depth is n and the total is O(n squared). Choose a random pivot or median-of-three, recurse into the smaller side first to bound stack depth at O(log n), and use introsort (fall back to heapsort) if you need a guaranteed O(n log n).
7 Detect a cycle in a linked list and find where it starts.
mediumUse Floyd's algorithm. Move slow by one and fast by two. If they meet there is a cycle. Then reset one pointer to the head and move both one step at a time: they meet at the cycle start, because the distance from head to the start equals the distance from the meeting point to the start going round the loop. Time O(n), space O(1). The hash-set version is O(n) space, which is what the interviewer will push you to remove.
pythondef cycle_start(head): slow = fast = head while fast and fast.next: slow, fast = slow.next, fast.next.next if slow is fast: slow = head while slow is not fast: slow, fast = slow.next, fast.next return slow return Nonejavaclass ListNode { int val; ListNode next; } class Solution { ListNode cycleStart(ListNode head) { ListNode slow = head, fast = head; while (fast != null && fast.next != null) { slow = slow.next; fast = fast.next.next; if (slow == fast) { slow = head; while (slow != fast) { slow = slow.next; fast = fast.next; } return slow; } } return null; } }8 Why is appending to a dynamic array O(1) amortised?
easyWhen the array is full it allocates double the capacity and copies every element, an O(n) step. But that copy happens only after n cheap appends, and the copy sizes form 1 + 2 + 4 + ... up to n, which sums to less than 2n. Spread over n appends, the total cost is O(n), so each append averages O(1). Growth by a constant factor is what matters: growing by a fixed number of slots would make appends O(n) amortised.
9 BFS or DFS: how do you decide, and what does each cost?
mediumBoth visit every vertex and edge once, so time is O(V + E). BFS uses a queue and finds shortest paths in unweighted graphs, so use it for 'minimum steps' problems such as word ladder or grid distance. DFS uses recursion or a stack with O(depth) space and suits connected components, cycle detection, topological ordering and backtracking. Mention recursion depth limits for DFS on large inputs and switch to an explicit stack.
10 You are given a function that merges overlapping intervals. How would you test it?
mediumGoogle interviewers often ask for tests after the code. List categories: empty input, one interval, already disjoint, fully nested, touching at a boundary (does [1,2] and [2,3] merge?), unsorted input, duplicates, negative values, and very large input for performance. Ask the interviewer to define whether touching intervals merge. Then pick a few concrete cases with expected outputs and walk the code on one of them. Naming the boundary ambiguity yourself is the strongest signal.
11 Tell me about a time you disagreed with a teammate about a technical approach.
mediumUse the STAR structure from the behavioural interview guide. Situation: two of you wanted different designs for a feature. Task: you owned the decision or the deadline. Action: you wrote down both options with their costs, ran a small experiment or benchmark, and agreed on a decision rule up front. Result: the data picked the winner, you shipped, and the relationship stayed intact. Avoid stories where you simply won the argument, and pick one where you changed your mind if you can.
12 Describe a project where the requirements were unclear. What did you do?
mediumShow how you create structure. A good answer: you listed assumptions, asked the people who would use the output what decision it informed, built the smallest version that tested the riskiest assumption, and shared it early. Give a concrete result, such as cutting scope after the first demo. For a fresher, a college project, hackathon or internship task is fine, provided you say specifically what you decided and why.
13 Tell me about something you built that failed or that you would do differently.
easyPick a real failure with a contained cost, for example a project that missed its deadline or a design that did not scale. Say what you got wrong, what signal you missed, and what you changed afterwards, such as adding tests, estimating more carefully or asking for review sooner. The goal is to show learning that changed your behaviour, not to disguise a strength as a weakness.
14 What happens, step by step, when you type a URL into a browser and press enter?
mediumThe browser checks its cache, then resolves the hostname through DNS to an IP address. It opens a TCP connection, then does a TLS handshake for HTTPS, sends an HTTP request, and receives the response. It parses the HTML into the DOM, fetches CSS, JavaScript and images, builds the render tree, lays it out and paints. A strong answer adds one depth point, such as how HTTP caching headers or HTTP/2 multiplexing change this, rather than listing steps only.
Frequently asked questions
Do Google interviews allow pseudocode?
Google's older internship guide says pseudocode is generally not wanted and that you should write real code in a language you choose. Check your recruiter's current instructions.
How many interview rounds does Google have for SDE roles in India?
Google does not publish a fixed number for India. Its public guidance describes technical interviews followed by further interviews, so ask your recruiter for the exact loop.
Are Google questions only about data structures and algorithms?
Coding is central, but Google also expects reasoning about trade-offs, testing your code and behavioural stories. Senior roles add design discussions.
Where do I find Google's current openings?
Use Google hiring for the sourced summary, then Google's own careers site for live roles.
Sources
Related guides
- Google Coding Round Questions with Solutions in Python and Java
- Amazon Interview Questions and Answers for SDE Roles
- Microsoft Interview Questions and Answers for SDE Roles
- System Design Interview Questions with Worked Designs
- STAR Method: Behavioural Interview Questions and Answers
- Graph Interview Questions and Answers
More in Company Interview Questions
- Groww Coding Round Questions With Solutions
- Groww Interview Questions and Answers
- HCLTech Coding Round Questions with Solutions
- HCLTech Interview Questions for Freshers
- Hexaware Coding Round Questions with Solutions
- Hexaware Interview Questions for Freshers
- Honeywell Coding Round Questions with Solutions
- Honeywell Interview Questions and Answers for India Engineering Roles
- HSBC coding round questions with solutions
- HSBC interview questions with answers (technology graduates)
- IBM coding round questions
- IBM interview questions and answers