Skip to main content

Google Coding Interview Questions

26 Google coding interview problems with full optimal solutions — 2 easy, 13 medium, 11 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an Google interviewer values, and a FAQ section.

  • #1easyfoundational

    1. Two Sum

    Two Sum is Google's canonical warm-up: given an integer array and a target, return the indices of the two numbers that add up to the target. The interviewer is grading your willingness to narrate the space-for-time tradeoff before jumping to the optimal.

    4 free resourcesSolve →
  • #3mediumfrequently asked

    3. Longest Substring Without Repeating Characters

    Given a string, return the length of the longest substring with all unique characters. Google asks this to test sliding-window intuition and whether you can articulate why O(n) is achievable when the naive answer is O(n^3).

  • #4hardless common

    4. Median of Two Sorted Arrays

    Given two sorted arrays, return the median of the combined array in O(log(min(m, n))). Google asks this to test whether you can apply binary search on the smaller array's partition position — one of the hardest applications of the binary-search paradigm.

  • #5mediumfrequently asked

    5. Longest Palindromic Substring

    Find the longest palindromic substring in a given string. Google asks this to test whether you reach for the expand-around-center technique and can articulate why it's O(n^2) instead of the naive O(n^3).

  • #10hardless common

    10. Regular Expression Matching

    Implement regex matching with '.' and '*'. Google asks this to test whether you can set up a 2D DP for a problem where the recurrence has multiple branches depending on what character pattern[j-1] is.

  • #20easyfoundational

    20. Valid Parentheses

    Given a string of brackets, return true if every opener has a matching, correctly-nested closer. Google asks this to confirm you can model push/pop state with a stack and articulate why the LIFO property is what makes the problem cleanly solvable.

  • #23hardfrequently asked

    23. Merge k Sorted Lists

    Given k sorted linked lists, merge them into one sorted linked list. Google asks this to see whether you reach for a min-heap, can articulate the n log k vs nk tradeoff, and know how to compare two linked-list nodes inside a priority queue.

  • #33mediumfrequently asked

    33. Search in Rotated Sorted Array

    Search for a target in a sorted array that has been rotated at some unknown pivot. Google asks this to test whether you can apply modified binary search and reason about which half is sorted at each step.

  • #42hardfrequently asked

    42. Trapping Rain Water

    Given heights, compute how much water trapped between bars after rain. Google asks this to see whether you reach for the two-pointer invariant (water at i depends only on min(maxLeft, maxRight)) without falling into the O(n^2) trap of recomputing maxes per index.

  • #53mediumfrequently asked

    53. Maximum Subarray

    Find the contiguous subarray with the largest sum. Google asks this to see whether you arrive at Kadane's algorithm and can articulate the invariant: at index i, the best subarray ending here is either the current element alone or the current element extending the previous best.

  • #68hardfrequently asked

    68. Text Justification

    Given an array of words and a max line width, format the text so each line is fully justified. Google asks this to see whether you can manage the edge cases (last line, single-word lines, uneven space distribution) without losing track.

  • #72hardfrequently asked

    72. Edit Distance

    Given two strings, return the minimum number of insertions, deletions, and substitutions to transform one into the other. Google asks this to test whether you can set up a 2D DP recurrence cleanly and articulate why each character pair has exactly four sub-choices.

  • #91mediumfrequently asked

    91. Decode Ways

    Given a digit string, count the ways it can be decoded as letters (A=1...Z=26). Google asks this to test whether you reach for 1D DP and can handle the edge cases around '0' digits which can't stand alone.

  • #124hardfrequently asked

    124. Binary Tree Maximum Path Sum

    Find the maximum sum path in a binary tree, where the path can start and end at any node. Google asks this to test whether you can separate two concepts at the same recursive node: the best path that 'extends upward' versus the best path that 'turns at this node and goes nowhere else.'

  • #127hardfrequently asked

    127. Word Ladder

    Given a begin word, end word, and word list, return the length of the shortest transformation sequence where each step changes one letter. Google asks this to test whether you reach for BFS on an implicit graph and can articulate why BFS (not DFS) is the right tool for shortest-path on unweighted edges.

  • #128mediumfrequently asked

    128. Longest Consecutive Sequence

    Given an unsorted array, find the length of the longest consecutive elements sequence. The catch: Google requires O(n) — sorting (O(n log n)) is the wrong answer and you must reach for the hash-set 'start a chain only from the smallest element' trick.

  • #139mediumfrequently asked

    139. Word Break

    Given a string and a dictionary, return true if the string can be segmented into dictionary words. Google asks this to test whether you reach for DP and can articulate why a hash set of words + a boolean DP table gives O(n^2) instead of the exponential backtracking blowup.

  • #146mediumfrequently asked

    146. LRU Cache

    Design a cache that evicts the least recently used key when full. Google asks this to test whether you reach for the doubly-linked-list + hash map combo and can articulate why neither data structure alone gives you O(1) for both get and put.

  • #207mediumfrequently asked

    207. Course Schedule

    Given courses and prerequisites, return true if all courses can be finished. Google asks this to test whether you reach for cycle detection in a directed graph and can articulate the difference between DFS-with-coloring and Kahn's BFS topological sort.

  • #212hardfrequently asked

    212. Word Search II

    Given a 2D board and a list of words, return all words on the board. Google asks this to test whether you reach for a trie + DFS combo and can articulate why it's drastically faster than running Word Search I once per word.

  • #253mediumfrequently asked

    253. Meeting Rooms II

    Given meeting intervals, return the minimum number of rooms required. Google asks this to test whether you reach for a min-heap of end times or the sweep-line / two-pointer counter, and can articulate the start/end event framing.

  • #295hardfrequently asked

    295. Find Median from Data Stream

    Maintain the median of a stream of numbers with O(log n) addNum and O(1) findMedian. Google asks this to test whether you reach for two heaps (max-heap of lower half + min-heap of upper half) and can articulate the size-balance invariant.

  • #297hardfrequently asked

    297. Serialize and Deserialize Binary Tree

    Encode a binary tree to a string and decode it back. Google asks this to test whether you handle null markers correctly and choose a traversal order that both serialize and deserialize can agree on without ambiguity.

  • #300mediumfrequently asked

    300. Longest Increasing Subsequence

    Return the length of the longest strictly increasing subsequence. Google asks this to test whether you reach for O(n log n) via patience sorting / binary search rather than stopping at the textbook O(n^2) DP.

  • #380mediumfrequently asked

    380. Insert Delete GetRandom O(1)

    Design a data structure that supports insert, remove, and getRandom — all in O(1) average. Google asks this to test whether you can combine a hash map (for O(1) lookup) with a dynamic array (for O(1) random access), and to see if you handle the 'swap to end before pop' trick for O(1) removal.

  • #399mediumfrequently asked

    399. Evaluate Division

    Given variable equations like a/b = 2.0 and b/c = 3.0, answer queries like a/c. Google asks this to test whether you can model the equations as a weighted graph and reach for DFS or union-find.

Related interview-prep guides

Interview Platforms

HireVue Tech Interview Guide: The 2026 Playbook for Async Video Rounds

HireVue is the category-leading async video interview platform. Candidates record answers solo, on the clock, and a combined AI-plus-human review layer scores the recording days later. For 2026 tech jobseekers, the format is different enough from live interviews to need its own playbook. This guide is that playbook.

Interview Platforms

HackerRank Tech Interview Guide 2026: What It Tests, How It Tracks You, and the Modern Setup

HackerRank is still the volume leader in first-round technical screens for 2026 tech hiring. A browser-sandboxed coding environment that logs every keystroke, paste event, and tab-focus change inside its own tab. This guide covers what it tests, the boundary of what it can and cannot detect, and how a modern desktop setup pairs with a HackerRank session without leaking into the screen-share.

Interview Platforms

Karat Technical Interview Guide 2026: How the Third-Party Loop Actually Works

Karat is technical-interview-as-a-service. Karat-employed engineers run the technical loop for the hiring company in Karat's own recorded video and coding environment. The dynamic is different from an in-house interview: the interviewer is a contractor, not a future teammate, the rubric is fixed, the session is recorded for asynchronous review, and the hiring team's engineers watch the playback a day later. This guide is the practical map of how that loop works in 2026 and how a modern desktop setup runs alongside it.

Google Coding Interview Questions — Full Solutions — InterviewChamp.AI