IC 150 — Complete Interview Prep

The complete superset of IC 75 — 150 questions across 8 weeks for a thorough, no-gaps prep, paired with our video roadmap.

Week 1

1-bit and 2-bit Characters

easy
We have two special characters: Given a binary array bits that ends with 0, return true if the last character must be a one-bit character.

Add to Array-Form of Integer

easy
The array-form of an integer num is an array representing its digits in left to right order.

Adjacent Increasing Subarrays Detection I

easy
Given an array nums of n integers and an integer k, determine whether there exist two adjacent subarrays of length k such that both subarrays are strictly increasing.

Alternating Groups I

easy
There is a circle of red and blue tiles.

Contains Duplicate II

easy
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) <= k.

Count Substrings That Satisfy K-Constraint I

easy
You are given a binary string s and an integer k.

Ant on the Boundary

easy
An ant is on a boundary.

Check if All the Integers in a Range Are Covered

easy
You are given a 2D integer array ranges and two integers left and right.

Count Partitions with Even Sum Difference

easy
You are given an integer array nums of length n.

Backspace String Compare

easy
Given two strings s and t, return true if they are equal when both are typed into empty text editors.

Clear Digits

easy
You are given a string s.

Crawler Log Folder

easy
A file system keeps a log each time some user performs a change folder operation.

First Unique Character in a String

easy
Given a string s, find the first non-repeating character in it and return its index.

Number of Students Unable to Eat Lunch

easy
The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively.

Time Needed to Buy Tickets

easy
There are n people in a line queuing to buy tickets, where the 0th person is at the front of the line and the (n - 1)th person is at the back of the line.

Final Prices With a Special Discount in a Shop

easy
You are given an integer array prices where prices[i] is the price of the ith item in a shop.

Next Greater Element I

easy
The next greater element of some element x in an array is the first greater element that is to the right of x in the same array.

132 Pattern

medium
Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j].

Continuous Subarrays

medium
You are given a 0-indexed integer array nums.

Count Partitions With Max-Min Difference at Most K

medium
You are given an integer array nums and an integer k.

Count Prime-Gap Balanced Subarrays

medium
You are given an integer array nums and an integer k.

Week 2

Apple Redistribution into Boxes

easy
You are given an array apple of size n and an array capacity of size m.

Apply Operations to an Array

easy
You are given a 0-indexed array nums of size n consisting of non-negative integers.

Array Partition

easy
Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized.

Defuse the Bomb

easy
You have a bomb to defuse, and your time is running out!

Find the K-Beauty of a Number

easy
The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions: Given integers num and k, return the...

Find X-Sum of All K-Long Subarrays I

easy
You are given an array nums of n integers and two integers k and x.

Find Pivot Index

easy
Given an array of integers nums, calculate the pivot index of this array.

Find the Highest Altitude

easy
There is a biker going on a road trip.

Find the Middle Index in Array

easy
Given a 0-indexed integer array nums, find the leftmost middleIndex (i.e., the smallest amongst all the possible ones).

Make The String Great

easy
Given a string s of lower and upper case English letters.

Maximum Nesting Depth of the Parentheses

easy
Given a valid parentheses string s, return the nesting depth of s.

Minimum String Length After Removing Substrings

easy
You are given a string s consisting only of uppercase English letters.

Dota2 Senate

medium
In the world of Dota2, there are two parties: the Radiant and the Dire.

Find the Winner of the Circular Game

medium
There are n friends that are playing a game.

Jump Game VI

medium
You are given a 0-indexed integer array nums and an integer k.

Beautiful Towers I

medium
You are given an array heights of n integers representing the number of bricks in n consecutive towers.

Beautiful Towers II

medium
You are given a 0-indexed array maxHeights of n integers.

Car Fleet

medium
There are n cars at given miles away from the starting mile 0, traveling to reach the mile target.

Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit

medium
Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray...

Maximum Sum Circular Subarray

medium
Given a circular integer array nums of length n, return the maximum possible sum of a non-empty subarray of nums.

Minimum Number of Coins for Fruits

medium
You are given an 0-indexed integer array prices where prices[i] denotes the number of coins needed to purchase the (i + 1)th fruit.

Week 3

Linked List Cycle Detection

easy
Determine whether a singly-linked list loops back on itself instead of ending in null.

Merge Two Sorted Linked Lists

easy
Splice two sorted singly-linked lists together into a single sorted list.

Middle of the Linked List

easy
Find the value stored in the middle node of a singly-linked list in a single pass.

Arranging Coins

easy
You have n coins and you want to build a staircase with these coins.

Binary Search

easy
Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums.

Check If N and Its Double Exist

easy
Given an array arr of integers, check if there exist two indices i and j such that :

Delete Greatest Value in Each Row

easy
You are given an m x n matrix grid consisting of positive integers.

Final Array State After K Multiplication Operations I

easy
You are given an integer array nums, an integer k, and an integer multiplier.

Find Subsequence of Length K With the Largest Sum

easy
You are given an integer array nums and an integer k.

Assign Cookies

easy
Assume you are an awesome parent and want to give your children some cookies.

Buy Two Chocolates

easy
You are given an integer array prices representing the prices of various chocolates in a store.

Can Place Flowers

easy
You have a long flowerbed in which some of the plots are planted, and some are not.

Count Prefix and Suffix Pairs I

easy
You are given a 0-indexed string array words.

Longest Common Prefix

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

Maximum Strong Pair XOR I

easy
You are given a 0-indexed integer array nums.

Get All Root-to-Leaf Paths

easy
Return every root-to-leaf path in a binary tree as a list of node values, instead of an arrow-joined string.

Binary Tree Paths

easy
Return every root-to-leaf path in a binary tree as an arrow-joined string.

Binary Watch

easy
A binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent the minutes (0-59).

Week 4

Minimum Pair Removal to Sort Array I

easy
Given an array nums, you can perform the following operation any number of times: Return the minimum number of operations needed to make the array non-decreasing.

Palindrome Linked List

easy
Check whether the values in a singly-linked list read the same forwards and backwards.

Remove Duplicates From a Sorted Linked List

easy
Collapse consecutive duplicate values in a sorted singly-linked list so each value appears once.

Count Negative Numbers in a Sorted Matrix

easy
Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.

Count the Number of Incremovable Subarrays I

easy
You are given a 0-indexed array of positive integers nums.

Fair Candy Swap

easy
Alice and Bob have a different total number of candies.

Largest Number After Digit Swaps by Parity

easy
You are given a positive integer num.

Last Stone Weight

easy
You are given an array of integers stones where stones[i] is the weight of the ith stone.

Make Array Zero by Subtracting Equal Amounts

easy
You are given a non-negative integer array nums.

DI String Match

easy
A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where: Given a string s, reconstruct the permutation perm...

Distribute Money to Maximum Children

easy
You are given an integer money denoting the amount of money (in dollars) that you have and another integer children denoting the number of children that you must distribute the...

K Items With the Maximum Sum

easy
There is a bag that consists of items, each item has a number 1, 0, or -1 written on it.

Camelcase Matching

medium
Given an array of strings queries and a string pattern, return a boolean array answer where answer[i] is true if queries[i] matches pattern, and false otherwise.

Extra Characters in a String

medium
You are given a 0-indexed string s and a dictionary of words dictionary.

Find the Length of the Longest Common Prefix

medium
You are given two arrays with positive integers arr1 and arr2.

Sum of All Subset XOR Totals

easy
The XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty.

Additive Number

medium
An additive number is a string whose digits can form an additive sequence.

All Paths From Source to Target

medium
Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any order.

Week 5

Binary Tree Basics

easy
An introduction to the Node and BinTree building blocks used throughout the Binary Trees series, plus a sample tree these exercises build on.

Binary Tree Traversals: Preorder, Inorder, Postorder

easy
Add preorder, inorder, and postorder traversal methods to BinTree and see how each visits the same sample tree in a different order.

Convert a Sorted Array to a Balanced BST

easy
Build a height-balanced binary search tree from an array sorted in ascending order.

Find if Path Exists in Graph

easy
There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive).

Flood Fill

easy
You are given an image represented by an m x n grid of integers image, where image[i][j] represents the pixel value of the image.

Island Perimeter

easy
You are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water.

01 Matrix

medium
Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell.

Accounts Merge

medium
Given a list of accounts where each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails...

As Far from Land as Possible

medium
Given an n x n grid containing only values 0 and 1, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized,...

Find Center of Star Graph

easy
There is an undirected star graph consisting of n nodes labeled from 1 to n.

Find the Town Judge

easy
In a town, there are n people labeled from 1 to n.

Cheapest Flights Within K Stops

medium
There are n cities connected by some number of flights.

Course Schedule

medium
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1.

Course Schedule II

medium
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1.

Course Schedule IV

medium
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1.

Check if There is a Valid Path in a Grid

medium
You are given an m x n grid.

Count Islands With Total Value Divisible by K

medium
You are given an m x n matrix grid and a positive integer k.

Count Servers that Communicate

medium
You are given a map of a server center, represented as a m * n integer matrix grid, where 1 means that on that cell there is a server and 0 means that it is no server.

Week 6

Invert Binary Tree

easy
Flip a binary tree into its mirror image by swapping every node's left and right children.

Minimum Absolute Difference in a BST

easy
Find the smallest absolute difference between the values of any two distinct nodes in a binary search tree.

Range Sum of a BST

easy
Sum every node value in a binary search tree that falls within a given inclusive range.

Array Nesting

medium
You are given an integer array nums of length n where nums is a permutation of the numbers in the range [0, n - 1].

Battleships in a Board

medium
Given an m x n matrix board where each cell is a battleship 'X' or empty '.', return the number of the battleships on board.

Bulb Switcher II

medium
There is a room with n bulbs labeled from 1 to n that all are turned on initially, and four buttons on the wall.

Check Knight Tour Configuration

medium
There is a knight on an n x n chessboard.

Coin Change

medium
You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

Coloring A Border

medium
You are given an m x n integer matrix grid, and three integers row, col, and color.

Count the Number of Complete Components

medium
You are given an integer n.

Count the Number of Houses at a Certain Distance I

medium
You are given three positive integers n, x, and y.

Count Unreachable Pairs of Nodes in an Undirected Graph

medium
You are given an integer n.

Find All Possible Recipes from Given Supplies

medium
You have information about n different recipes.

Find Eventual Safe States

medium
There is a directed graph of n nodes with each node labeled from 0 to n - 1.

Loud and Rich

medium
There is a group of n people labeled from 0 to n - 1 where each person has a different amount of money and a different level of quietness.

Count Sub Islands

medium
You are given two m x n binary matrices grid1 and grid2 containing only 0's (representing water) and 1's (representing land).

Detect Cycles in 2D Grid

medium
Given a 2D array of characters grid of size m x n, you need to find if there exists any cycle consisting of the same value in grid.

Evaluate Division

medium
You are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] represent the equation Ai / Bi = values[i].

Week 7

Digit Operations to Make Two Integers Equal

medium
You are given two integers n and m that consist of the same number of digits.

Find a Safe Walk Through a Grid

medium
You are given an m x n binary matrix grid and an integer health.

Find Minimum Time to Reach Last Room I

medium
There is a dungeon with n x m rooms arranged as a grid.

Min Cost to Connect All Points

medium
You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].

Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree

hard
Given a weighted undirected connected graph with n vertices numbered from 0 to n - 1, and an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional and weighted...

Maximize Spanning Tree Stability with Upgrades

hard
You are given an integer n, representing n nodes numbered from 0 to n - 1 and a list of edges, where edges[i] = [ui, vi, si, musti]: You are also given an integer k, the maximum...

Cracking the Safe

hard
There is a safe protected by a password.

Critical Connections in a Network

hard
There are n servers numbered from 0 to n - 1 connected by undirected server-to-server connections forming a network where connections[i] = [ai, bi] represents a connection between...

Minimum Edge Weight Equilibrium Queries in a Tree

hard
There is an undirected tree with n nodes labeled from 0 to n - 1.

Best Time to Buy and Sell Stock

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

Climbing Stairs

easy
You are climbing a staircase.

Counting Bits

easy
Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i.

Fruits Into Baskets II

easy
You are given two arrays of integers, fruits and baskets, each of length n, where fruits[i] represents the quantity of the ith type of fruit, and baskets[j] represents the...

Count Number of Teams

medium
There are n soldiers standing in a line.

Fruits Into Baskets III

medium
You are given two arrays of integers, fruits and baskets, each of length n, where fruits[i] represents the quantity of the ith type of fruit, and baskets[j] represents the...

Count Number of Rectangles Containing Each Point

medium
You are given a 2D integer array rectangles where rectangles[i] = [li, hi] indicates that ith rectangle has a length of li and a height of hi.

Maximum Area Rectangle With Point Constraints I

medium
You are given an array points where points[i] = [xi, yi] represents the coordinates of a point on an infinite plane.

Number of Longest Increasing Subsequence

medium
Given an integer array nums, return the number of longest increasing subsequences.

Week 8

Find Minimum Time to Reach Last Room II

medium
There is a dungeon with n x m rooms arranged as a grid.

Find the City With the Smallest Number of Neighbors at a Threshold Distance

medium
There are n cities numbered from 0 to n-1.

Minimize the Maximum Edge Weight of Graph

medium
You are given two integers, n and threshold, as well as a directed weighted graph of n nodes numbered from 0 to n - 1.

Minimum Number of Days to Disconnect Island

hard
You are given an m x n binary grid grid where 1 represents land and 0 represents water.

Reconstruct Itinerary

hard
You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight.

Valid Arrangement of Pairs

hard
You are given a 0-indexed 2D integer array pairs where pairs[i] = [starti, endi].

Divisor Game

easy
Alice and Bob take turns playing a game, with Alice starting first.

Fibonacci Number

easy
The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1.

Is Subsequence

easy
Given two strings s and t, return true if s is a subsequence of t, or false otherwise.

Minimum Number of Valid Strings to Form Target I

medium
You are given an array of strings words and a string target.

Queue Reconstruction by Height

medium
You are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order).

Block Placement Queries

hard
There exists an infinite number line, with its origin at 0 and extending towards the positive x-axis.

Queries on a Permutation With Key

medium
Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the following rules: Return an array...

Alternating Groups III

hard
There are some red and blue tiles arranged circularly.

Count Good Triplets in an Array

hard
You are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1].