Google Interview QuestionsStudy programming and algorithm questions
Find the middle element of a linked list
Method to find the middle element of a linked list in linear time.
Two sum problem
A popular interview question that requires you to determine if two numbers in an array sum to a specific value. A solution can be written that runs in linear time.
Print the power set of a given set
Solution for printing all possible subsets of a given set.
Subset sum problem
Important computer science question where the goal is to find a subset that sums to some number.
Determine if a tree is a subtree of a larger binary tree
Use tree traversal algorithms to solve this tree algorithm question.
Generate all balanced bracket combinations
Interesting question that asks you to print all combinations of pairs of brackets.
Find all string combinations of only 0, 1 and ?
Print all possible strings of 0's and 1's where the ? is a wildcard.
Insert an interval into a list of sorted disjoint intervals
Solution for inserting an interval into an already sorted list of disjoint intervals.
Implement a queue using two stacks
Solution for how to implement a queue using the stack data structure.
Counting steps using recursion
Recursion is an important topic to understand when learning a language, so this tutorial provides a simple example.
Stock maximum profit
Solution that explains how to calculate the maxiumum profit that could be made in a list of stock prices.
Quickly calculate the cube root of a number
Algorithm to calculate the cube root of a given number in constant time.
Powers of Two
For this challenge you will be determining whether or not a number is a power of two.
8597 solutions
Solution
Other Products
For this challenge you will return the product of a set of elements in an array.
1984 solutions
Solution
Wave Sorting
For this challenge you will determine if numbers in an array can be sorted in a particular way.
1361 solutions
Solution
Longest Increasing Sequence
For this challenge you will compute the length of the longest increasing subsequence.
1435 solutions
Solution
Power Set Count
For this challenge you will determine the length of a power set.
1153 solutions
Solution
Food Distribution
For this challenge you will determine how to optimally distribute food to people.
739 solutions
Solution
Correct Path
For this challenge you will be traversing a matrix searching for the correct path to take.
2304 solutions
Solution
String Periods
For this challenge you will need to find the smallest repeating substring.
578 solutions
Solution
Moving Median
For this challenge you will calculate the median in an array within a sliding window.
241 solutions
Solution
Array Addition
For this challenge you will determine if numbers in an array can add up to a certain number in the array.
4650 solutions
Solution
Binary Search Tree LCA
For this challenge you will attempt to find the lowest common ancestor of a binary search tree.
367 solutions
Solution
K Unique Characters
For this challenge you will be searching a string for a particular substring.
544 solutions
Solution
Symmetric Tree
For this challenge you will traverse a binary tree and determine if it is symmetric.
318 solutions
Solution
Binary Tree LCA
For this challenge you will attempt to find the lowest common ancestor of a binary tree.
184 solutions
Solution
Tree Constructor
For this challenge you will determine if an array of integer pairs can form a binary tree properly.
420 solutions
Solution
Word Split
For this challenge you will attempt to split a long string of characters into actual words.
460 solutions
Solution
Palindromic Substring
For this challenge you will be finding the longest palindromic substring.
306 solutions
Solution
Trapping Water
For this challenge you will determine the largest amount of water you can trap within a boundary.
198 solutions
Solution
Matrix Path
For this challenge you will determine if a path exists in a boolean matrix.
112 solutions
Solution
Seating Students
For this challenge you will determine how many different ways students can sit next to each other.
226 solutions
Solution
Longest Matrix Path
For this challenge you will be searching for the longest path in a 2D matrix.
87 solutions
Solution
Min Window Substring
For this challenge you will be searching for the optimal substring of k characters.
189 solutions
Solution
Three Points
For this challenge you will be plotting a line on a Cartesian grid.
166 solutions
Solution
Longest Consecutive
For this challenge you will compute the length of the longest consecutive subsequence.
359 solutions
Solution
Plus Minus
For this challenge you will need to determine how to add or subtract numbers to end up with zero.
207 solutions
Solution
Optimal Assignments
For this challenge you will be optimally assigning tasks to a number of machines.
556 solutions
Solution
Shortest Path
For this challenge you will have to determine the shortest path from one node to an end node.
1292 solutions
Solution
Pattern Chaser
For this challenge you will be given a string and you will have to determine whether some sort of pattern exists.
796 solutions
Solution
Weighted Path
For this challenge you will have to determine the shortest weighted path from one node to an end node.
379 solutions
Solution
Gas Station
For this challenge you will be determining whether a car can get around a route with a limited amount of gas.
616 solutions
Solution
Parallel Sums
For this challenge you will determine how to properly split an array into two sets.
181 solutions
Solution
Pascals Triangle
For this challenge you will determine the next number in a row from Pascal's triangle.
134 solutions
Solution
Bracket Combinations
This challenge will require knowledge of basic mathematical combinations.
154 solutions
Solution
Maximal Square
For this challenge you will be searching a matrix for the largest square submatrix.
2794 solutions
Solution
Maximal Rectangle
For this challenge you will be searching a matrix for the largest rectangle submatrix.
58 solutions
Solution
Bipartite Matching
For this challenge you will be finding the maximum cardinality matching of a bipartite graph.
55 solutions
Solution
City Traffic
For this challenge you will be finding the maximum traffic that will enter a node.
92 solutions
Solution
Wildcard Characters
For this challenge you will determine if a string matches a set of wildcard characters.
120 solutions
Solution