Technical Interview Questions and Solutions

Browse our database of interview questions and full-length solutions from top companies

MEDIUM
Data Structures and Algorithms
Build a Max Heap

Given an array of integers, transform the array in-place to a max heap.

Watch 1 interview
EASY
Data Structures and Algorithms
Reverse Linked List

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

Watch 2 interviews
MEDIUM
Mathematics
Reverse Integer

Given a 32-bit signed integer, reverse digits of the integer.

Watch 1 interview
MEDIUM
Data Structures and Algorithms
Find Peak Element

Given a two-dimensional binary matrix where 1 represents water and 0 represents land, mutate the matrix in place and return the matrix with the highest peak maximized.

MEDIUM
Data Structures and Algorithms
Recover Binary Search Tree

Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure.

Watch 1 interview
MEDIUM
Data Structures and Algorithms
Simplify Path

You are given a path to a file as a string. The path can contain the symbols: “..” for the parent directory and “.” for the current directory. Convert the path into its simplified form.

MEDIUM
Data Structures and Algorithms
Count Complete Tree Nodes

Given the root of a complete binary tree, return the number of nodes in the tree.

Watch 1 interview
MEDIUM
Data Structures and Algorithms
Boundary of Binary Tree

The boundary of a binary tree is the concatenation of the root, the left boundary, the leaves ordered from left-to-right, and the reverse order of the right boundary.

Watch 1 interview
MEDIUM
Data Structures and Algorithms
Three Sum

Given an array of integers, return an array of triplets such that i != j != k and nums[i] + nums[j] + nums[k] = 0.

Watch 1 interview
MEDIUM
Data Structures and Algorithms
Top K Frequent Elements

Given a non-empty array of integers, return the k most frequent elements

MEDIUM
Data Structures and Algorithms
K Closest Points To Origin

Given a list of tuples that represent (X, Y) coordinates on an XY plane and an integer K, return a list of the K-closest points to the origin (0, 0).

Watch 7 interviews
MEDIUM
Data Structures and Algorithms
Generate Parentheses

Given `n` pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

Watch 1 interview
EASY
Data Structures and Algorithms
Reverse Words in a String

Given an input string `s`, reverse the order of the words without reversing the words themselves.

Watch 1 interview
MEDIUM
Data Structures and Algorithms
Longest Common Subsequence

Given two strings, return the longest common subsequence between the two strings.

Watch 1 interview
MEDIUM
Data Structures and Algorithms
Copy List With Random Pointers

Given a linked list with nodes that have an additional pointer referring to another node in the list, return a deep copy of the list.

Watch 2 interviews
MEDIUM
Find Leaves of Binary Tree

Given a binary tree, extract all the leaves in repeated succession into a list of lists by starting at the bottom and working your way upwards.

Watch 1 interview
MEDIUM
Data Structures and Algorithms
Insert Delete getRandom O(1)

Design and implement an efficient sampler that works in average O(1) time complexity.

MEDIUM
Data Structures and Algorithms
Decode String

Given an encoded string, return its decoded string.

Watch 1 interview
HARD
Data Structures and Algorithms
Alien Dictionary

You are given a list of lexicographically sorted words from an alien language. This language has a unique order. Return the alphabetical order of all the letters found in the list of words.

Watch 3 interviews
MEDIUM
Data Structures and Algorithms
Partition to K Equal Sum Subsets

Given an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal.

Watch 1 interview
MEDIUM
Data Structures and Algorithms
Partition List

Given a list of integers L and a number K, write a function that reorganizes L into three partitions: elements less than K, elements equal to K, and elements greater than K. No additional lists may be used.

Watch 1 interview
MEDIUM
Data Structures and Algorithms
Number of Islands

Given a 2D matrix, where "1" represents land and "0" represents water, count how many islands are present.

Watch 1 interview
MEDIUM
Data Structures and Algorithms
Longest Substring Without Repeating Characters

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

Watch 1 interview
MEDIUM
Data Structures and Algorithms
Find Missing Number In Array (Two Arrays)

Given an unsorted array of unique integers (size n + 1) and a first array identical to the second array but missing one integer (size n), find and output the missing integer.

Watch 1 interview
MEDIUM
Data Structures and Algorithms
Container With Most Water

Given n non-negative integers, find two lines that form a container that can hold the most amount of water.

Watch 1 interview
EASY
Data Structures and Algorithms
Reverse String

Write a program to reverse the given string.

Watch 2 interviews
EASY
Data Structures and Algorithms
Two Sum

Given an array of integers, return the indices of the two numbers that add up to a given target.

Watch 5 interviews
MEDIUM
Data Structures and Algorithms
Meeting Rooms

Given a list of meetings, represented as tuples with a start and an end time, determine the minimum number of rooms required to schedule all the meetings.

Watch 1 interview
MEDIUM
Data Structures and Algorithms
Subarray Sum Equals K

Given an unsorted array of integers and an integer k, find the number of subarrays whose sum equals k.

Watch 2 interviews
MEDIUM
Data Structures and Algorithms
Kth Smallest Element

Given an integer array and an integer k, return the kth smallest element in the array.

Watch 2 interviews
MEDIUM
Data Structures and Algorithms
Right View Of Binary Tree

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.

Watch 1 interview

We know exactly what to do and say to get the company, title, and salary you want.

Interview prep and job hunting are chaos and pain. We can help. Really.