Problem database last updated: June 20, 2025

GGoogle logo

Google Coding Interview Questions

79 problems · 19 Easy, 42 Medium, 18 Hard · Ranked #31 of 458

Difficulty breakdown

19 Easy

24% · avg 23%

42 Medium

53% · avg 59%

18 Hard

23% · avg 18%

Top topics

array
44.3%
string
26.6%
dynamic-programming
16.5%
hash-table
16.5%
tree
13.9%2.5x
depth-first-search
13.9%1.5x

Interview profile

Based on 79 reported problems, Google interviews are slightly harder than average - 23% Hard vs 18% across all companies. The majority (53%) 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 binary-indexed-tree (2.5% of problems, 5.7x the industry average), segment-tree (2.5% of problems, 4.2x the industry average), database (3.8% of problems, 3.4x the industry average). If you're short on time, these are the categories to double down on.

The most common topics are array (44.3%), string (26.6%), dynamic-programming (16.5%), hash-table (16.5%). Problems below are sorted by frequency, the ones at the top are asked most often.

All 79 problems

Two Sum

Solve

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

EasyVery Likely
arrayhash-map

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

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

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

Maximum Subarray

Solve

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

MediumLikely
arraydivide-and-conquerdynamic-programming

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

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

Group Anagrams

Solve

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

MediumLikely
arrayhash-tablestring

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

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

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

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

Isomorphic Strings

Solve

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

EasySometimes
hash-tablestring

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

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

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

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

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

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

Second Highest Salary

Solve

Table: Employee

MediumSometimes
database

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

Basic Calculator II

Solve

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

MediumSometimes
mathstringstack

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

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

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

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

Combinations

Solve

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

MediumSometimes
backtracking

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

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

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

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

Minimum Depth of Binary Tree

Solve

Given a binary tree, find its minimum depth.

EasyRare
treedepth-first-searchbreadth-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

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

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

Gray Code

Solve

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

MediumRare
mathbacktrackingbit-manipulation

Valid Number

Solve

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

HardRare
string

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

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

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, dynamic-programming 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 458 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 79 distinct coding problems. The most common topics are array, string, dynamic-programming. 19 are Easy difficulty, 42 are Medium, and 18 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 79 reported problems, Google interviews are slightly harder than average - 23% Hard vs 18% across all companies. 53% 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, dynamic-programming. 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