Problem database last updated: June 20, 2025

GGoogle logo

Google Coding Interview Questions

101 problems · 20 Easy, 58 Medium, 23 Hard · Ranked #7 of 459

Difficulty breakdown

20 Easy

20% · avg 23%

58 Medium

57% · avg 59%

23 Hard

23% · avg 18%

Top topics

array
48.5%
string
26.7%
hash-table
17.8%
depth-first-search
16.8%1.8x
dynamic-programming
14.9%
sorting
13.9%

Interview profile

Based on 101 reported problems, Google interviews are slightly harder than average - 23% Hard vs 18% across all companies. The majority (57%) of questions are Medium difficulty, which is typical for companies that want to see solid fundamentals without excessive trick questions.

Compared to the industry average, Google puts unusual emphasis on line-sweep (2% of problems, 9.6x the industry average), binary-indexed-tree (2% of problems, 4.5x the industry average), segment-tree (2% of problems, 3.3x the industry average). If you're short on time, these are the categories to double down on.

The most common topics are array (48.5%), string (26.7%), hash-table (17.8%), depth-first-search (16.8%). Problems below are sorted by frequency, the ones at the top are asked most often.

All 101 problems

Two Sum

Solve

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

EasyVery Likely
arrayhash-table

Meeting Rooms II

Solve

Given an array of meeting time intervals intervals where intervals[i] = [starti, endi], return the minimum number of conference rooms required.

MediumVery Likely
arraytwo-pointersgreedy

Alien Dictionary

Solve

There is a new alien language that uses the English alphabet. However, the order of the letters is unknown to you.

HardVery Likely
arraystringdepth-first-search

Encode and Decode Strings

Solve

Design an algorithm to encode a list of strings to a single string. The encoded string is then decoded back to the original list of strings.

MediumVery Likely
arraystringdesign

Detect Squares

Solve

You are given a stream of points on the X-Y plane. Design a data structure that:

MediumVery Likely
arrayhash-tabledesign

Number of Good Paths

Solve

There is a tree of n nodes labeled from 0 to n - 1, rooted at node 0. You are given a 0-indexed integer array vals of length n where vals[i] denotes the value o...

HardVery Likely
arraytreeunion-find

Minimum Interval to Include Each Query

Solve

You are given a 2D integer array intervals, where intervals[i] = [lefti, righti] describes the ith interval starting at lefti and ending at righti (inclusive)....

HardVery Likely
arraybinary-searchline-sweep

Meeting Rooms

Solve

Given an array of meeting time intervals where intervals[i] = [starti, endi], determine if a person could attend all meetings.

EasyVery Likely
arraysorting

Graph Valid Tree

Solve

You have a graph of n nodes labeled from 0 to n - 1. You are given an integer n and a list of edges where edges[i] = [ai, bi] indicates that there is an undirec...

MediumVery Likely
depth-first-searchbreadth-first-searchunion-find

Add Two Numbers

Solve

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a sing...

MediumVery Likely
linked-listmathrecursion

Number of Connected Components in an Undirected Graph

Solve

You have a graph of n nodes. You are given an integer n and an array edges where edges[i] = [ai, bi] indicates that there is an edge between ai and bi in the gr...

MediumVery Likely
depth-first-searchbreadth-first-searchunion-find

Design Add and Search Words Data Structure

Solve

Design a data structure that supports adding new words and finding if a string matches any previously added string.

MediumVery Likely
stringdepth-first-searchdesign

Hand of Straights

Solve

Alice has some number of cards and she wants to rearrange the cards into groups so that each group is of size groupSize, and consists of groupSize consecutive c...

MediumVery Likely
arrayhash-tablegreedy

Naming a Company

Solve

You are given an array of strings ideas that represents a list of names to be used in the process of naming a company. The process of naming a company is as fol...

HardVery Likely
arrayhash-tablestring

Trapping Rain Water

Solve

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.

HardLikely
arraytwo-pointersdynamic-programming

Median of Two Sorted Arrays

Solve

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

HardLikely
arraybinary-searchdivide-and-conquer

Longest Substring Without Repeating Characters

Solve

Given a string s, find the length of the longest substring without duplicate characters.

MediumLikely
hash-tablestringsliding-window

Longest Common Prefix

Solve

Write a function to find the longest common prefix string amongst an array of strings.

EasyLikely
arraystringtrie

Time Needed to Inform All Employees

Solve

A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company is the one with headID.

MediumLikely
treedepth-first-searchbreadth-first-search

Valid Parentheses

Solve

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

EasyLikely
stringstack

Longest Consecutive Sequence

Solve

Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.

MediumLikely
arrayhash-tableunion-find

Remove Max Number of Edges to Keep Graph Fully Traversable

Solve

Alice and Bob have an undirected graph of n nodes and three types of edges:

HardLikely
union-findgraph

Push Dominoes

Solve

There are n dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or...

MediumLikely
stringtwo-pointersdynamic-programming

Merge Triplets to Form Target Triplet

Solve

A triplet is an array of three integers. You are given a 2D integer array triplets, where triplets[i] = [ai, bi, ci] describes the ith triplet. You are also giv...

MediumLikely
arraygreedy

Maximum Subarray

Solve

Given an integer array nums, find the subarray with the largest sum, and return its sum.

MediumLikely
arraydivide-and-conquerdynamic-programming

Grid Game

Solve

You are given a 0-indexed 2D array grid of size 2 x n, where grid[r][c] represents the number of points at position (r, c) on the matrix. Two robots are playing...

MediumLikely
arraymatrixprefix-sum

Unique Length-3 Palindromic Subsequences

Solve

Given a string s, return the number of unique palindromes of length three that are a subsequence of s.

MediumLikely
stringhash-tableprefix-sum

Find Eventual Safe States

Solve

There is a directed graph of n nodes with each node labeled from 0 to n - 1. The graph is represented by a 0-indexed 2D integer array graph where graph[i] is an...

MediumLikely
depth-first-searchbreadth-first-searchgraph

Rotate Image

Solve

You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).

MediumLikely
arraymathmatrix

Search in Rotated Sorted Array

Solve

There is an integer array nums sorted in ascending order (with distinct values).

MediumLikely
arraybinary-search

Reverse Linked List

Solve

Given the head of a singly linked list, reverse the list, and return the reversed list.

EasyLikely
linked-listrecursion

4Sum

Solve

Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that:

MediumLikely
arraytwo-pointerssorting

Jump Game

Solve

You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length...

MediumLikely
arraydynamic-programminggreedy

Single Number

Solve

Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.

EasyLikely
arraybit-manipulation

Pascal's Triangle

Solve

Given an integer numRows, return the first numRows of Pascal's triangle.

EasyLikely
arraydynamic-programming

Group Anagrams

Solve

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

MediumLikely
arrayhash-tablestring

Find Median from Data Stream

Solve

The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value, and the median is the mean of the two midd...

HardLikely
two-pointersdesignsorting

Find the Index of the First Occurrence in a String

Solve

Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.

EasyLikely
two-pointersstringstring-matching

Maximal Rectangle

Solve

Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.

HardLikely
arraydynamic-programmingstack

Valid Anagram

Solve

Given two strings s and t, return true if t is an anagram of s, and false otherwise.

EasyLikely
hash-tablestringsorting

First Missing Positive

Solve

Given an unsorted integer array nums. Return the smallest positive integer that is not present in nums.

HardLikely
arrayhash-table

Jump Game II

Solve

You are given a 0-indexed array of integers nums of length n. You are initially positioned at index 0.

MediumLikely
arraydynamic-programminggreedy

Add Binary

Solve

Given two binary strings a and b, return their sum as a binary string.

EasyLikely
mathstringbit-manipulation

Text Justification

Solve

Given an array of strings words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justifie...

HardSometimes
arraystringsimulation

Insert Interval

Solve

You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and interv...

MediumSometimes
array

Maximum Product Subarray

Solve

Given an integer array nums, find a subarray that has the largest product, and return the product.

MediumSometimes
arraydynamic-programming

String to Integer (atoi)

Solve

Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer.

MediumSometimes
string

Same Tree

Solve

Given the roots of two binary trees p and q, write a function to check if they are the same or not.

EasySometimes
treedepth-first-searchbreadth-first-search

Search a 2D Matrix

Solve

You are given an m x n integer matrix matrix with the following two properties:

MediumSometimes
arraybinary-searchmatrix

Wildcard Matching

Solve

Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '' where:

HardSometimes
stringdynamic-programminggreedy

Find the Duplicate Number

Solve

Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.

MediumSometimes
arraytwo-pointersbinary-search

Isomorphic Strings

Solve

Given two strings s and t, determine if they are isomorphic.

EasySometimes
hash-tablestring

3Sum Closest

Solve

Given an integer array nums of length n and an integer target, find three integers at distinct indices in nums such that the sum is closest to target.

MediumSometimes
arraytwo-pointerssorting

Missing Number

Solve

Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.

EasySometimes
arrayhash-tablemath

Contains Duplicate II

Solve

Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <=...

EasySometimes
arrayhash-tablesliding-window

Symmetric Tree

Solve

Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).

EasySometimes
treedepth-first-searchbreadth-first-search

Minimum Path Sum

Solve

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path.

MediumSometimes
arraydynamic-programmingmatrix

Kth Smallest Element in a BST

Solve

Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree.

MediumSometimes
treedepth-first-searchbinary-search-tree

Copy List with Random Pointer

Solve

A linked list of length n is given such that each node contains an additional random pointer, which could point to any node in the list, or null.

MediumSometimes
hash-tablelinked-list

Clone Graph

Solve

Given a reference of a node in a connected undirected graph.

MediumSometimes
hash-tabledepth-first-searchbreadth-first-search

Integer to Roman

Solve

Seven different symbols represent Roman numerals with the following values:

MediumSometimes
hash-tablemathstring

Shortest Palindrome

Solve

You are given a string s. You can convert s to a palindrome by adding characters in front of it.

HardSometimes
stringrolling-hashstring-matching

Flatten Binary Tree to Linked List

Solve

Given the root of a binary tree, flatten the tree into a "linked list":

MediumSometimes
linked-liststacktree

Word Search II

Solve

Given an m x n board of characters and a list of strings words, return all words on the board.

HardSometimes
arraystringbacktracking

Subsets II

Solve

Given an integer array nums that may contain duplicates, return all possible subsets (the power set).

MediumSometimes
arraybacktrackingbit-manipulation

Binary Tree Right Side View

Solve

Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.

MediumSometimes
treedepth-first-searchbreadth-first-search

Best Time to Buy and Sell Stock with Cooldown

Solve

You are given an array prices where prices[i] is the price of a given stock on the ith day.

MediumSometimes
arraydynamic-programming

The Skyline Problem

Solve

A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of...

HardSometimes
arraydivide-and-conquerbinary-indexed-tree

Implement Stack using Queues

Solve

Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (push, top, pop, and...

EasySometimes
stackdesignqueue

Second Highest Salary

Solve

Table: Employee

MediumSometimes
database

Basic Calculator II

Solve

Given a string s which represents an expression, evaluate this expression and return its value.

MediumSometimes
mathstringstack

Fraction to Recurring Decimal

Solve

Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.

MediumSometimes
hash-tablemathstring

Number of Digit One

Solve

Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.

HardSometimes
mathdynamic-programmingrecursion

Game of Life

Solve

According to Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway...

MediumSometimes
arraymatrixsimulation

Walls and Gates

Solve

You are given an m x n grid rooms initialized with these three possible values:

MediumSometimes
arraybreadth-first-searchmatrix

Binary Tree Paths

Solve

Given the root of a binary tree, return all root-to-leaf paths in any order.

EasySometimes
stringbacktrackingtree

Best Time to Buy and Sell Stock IV

Solve

You are given an integer array prices where prices[i] is the price of a given stock on the ith day, and an integer k.

HardSometimes
arraydynamic-programming

Wiggle Sort

Solve

Given an integer array nums, reorder it such that nums[0] <= nums[1] >= nums[2] <= nums[3]....

MediumSometimes
arraygreedysorting

Combinations

Solve

Given two integers n and k, return all possible combinations of k numbers chosen from the range [1, n].

MediumSometimes
backtracking

Lowest Common Ancestor of a Binary Search Tree

Solve

Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.

MediumSometimes
treedepth-first-searchbinary-search-tree

Binary Tree Postorder Traversal

Solve

Given the root of a binary tree, return the postorder traversal of its nodes' values.

EasySometimes
stacktreedepth-first-search

Department Top Three Salaries

Solve

Table: Employee

HardRare
database

Spiral Matrix II

Solve

Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order.

MediumRare
arraymatrixsimulation

Peeking Iterator

Solve

Design an iterator that supports the peek operation on an existing iterator in addition to the hasNext and the next operations.

MediumRare
arraydesigniterator

Remove Duplicates from Sorted List II

Solve

Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked li...

MediumRare
linked-listtwo-pointers

Factorial Trailing Zeroes

Solve

Given an integer n, return the number of trailing zeroes in n!.

MediumRare
math

Insertion Sort List

Solve

Given the head of a singly linked list, sort the list using insertion sort, and return the sorted list's head.

MediumRare
linked-listsorting

Scramble String

Solve

We can scramble a string s to get a string t using the following algorithm:

HardRare
stringdynamic-programming

Populating Next Right Pointers in Each Node

Solve

You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:

MediumRare
linked-listtreedepth-first-search

N-Queens II

Solve

The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.

HardRare
backtracking

Minimum Depth of Binary Tree

Solve

Given a binary tree, find its minimum depth.

EasyRare
treedepth-first-searchbreadth-first-search

Word Pattern

Solve

Given a pattern and a string s, find if s follows the same pattern.

EasyRare
hash-tablestring

Bitwise AND of Numbers Range

Solve

Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive.

MediumRare
bit-manipulation

Rank Scores

Solve

Table: Scores

MediumRare
database

Find Minimum in Rotated Sorted Array II

Solve

Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become:

HardRare
arraybinary-search

Valid Number

Solve

Given a string s, return whether s is a valid number.

HardRare
string

Gray Code

Solve

An n-bit gray code sequence is a sequence of 2n integers where:

MediumRare
mathbacktrackingbit-manipulation

Remove Invalid Parentheses

Solve

Given a string s that contains parentheses and letters, remove the minimum number of invalid parentheses to make the input string valid.

HardRare
stringbacktrackingbreadth-first-search

Range Sum Query - Mutable

Solve

Given an integer array nums, handle multiple queries of the following types:

MediumRare
arraydivide-and-conquerdesign

Binary Tree Level Order Traversal II

Solve

Given the root of a binary tree, return the bottom-up level order traversal of its nodes' values. (i.e., from left to right, level by level from leaf to root).

MediumRare
treebreadth-first-searchbinary-tree

Paint House

Solve

There is a row of n houses, where each house can be painted one of three colors: red, blue, or green. The cost of painting each house with a certain color is di...

MediumRare
arraydynamic-programming

How often are these problems asked?

Frequency scores are based on crowdsourced interview reports. A higher score means the problem has been reported more often in recent Google interviews.

Very Likely

75-100%

Likely

50-74%

Sometimes

25-49%

Rare

0-24%

Preparing for your Google coding interview

Google interviews focus heavily on array, string, hash-table problems. If you're short on time, these are the categories to prioritize. The problems on this page are sorted by frequency, so start from the top and work your way down.

Beyond solving problems, practice explaining your approach. Google interviewers care about your thought process - how you break down a problem, consider edge cases, and evaluate tradeoffs between solutions. A clean O(n) solution you can explain clearly beats an O(log n) solution you can't articulate.

Looking for more companies? Browse all 459 companies in our directory, or sharpen your fundamentals with our free data structure visualizers and AI-powered DSA tutor.

Frequently Asked Questions

What coding problems does Google ask in interviews?add

Google has been reported to ask 101 distinct coding problems. The most common topics are array, string, hash-table. 20 are Easy difficulty, 58 are Medium, and 23 are Hard. Problems are sorted by frequency - the ones at the top are asked most often.

How hard are Google coding interviews?add

Based on 101 reported problems, Google interviews are slightly harder than average - 23% Hard vs 18% across all companies. 57% of questions are Medium difficulty. Focus on the high-frequency Medium problems first, then work through the Hard ones.

How should I prepare for a Google coding interview?add

Start with the highest-frequency problems listed on this page. Focus on the core topics: array, string, hash-table. Practice solving them under time pressure and explaining your approach out loud. Mock interviews with AI can simulate the real experience.

Other companies to explore

Ready to ace your Google interview?

Simulate a real Google coding interview with an AI interviewer. Get a scorecard with specific feedback on your problem-solving, code quality, and communication.

Simulate a Google interview with AIarrow_forward