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
easyWe 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
easyThe array-form of an integer num is an array representing its digits in left to right order.
Adjacent Increasing Subarrays Detection I
easyGiven 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
easyThere is a circle of red and blue tiles.
Contains Duplicate II
easyGiven 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
easyYou are given a binary string s and an integer k.
Ant on the Boundary
easyAn ant is on a boundary.
Check if All the Integers in a Range Are Covered
easyYou are given a 2D integer array ranges and two integers left and right.
Count Partitions with Even Sum Difference
easyYou are given an integer array nums of length n.
Backspace String Compare
easyGiven two strings s and t, return true if they are equal when both are typed into empty text editors.
Clear Digits
easyYou are given a string s.
Crawler Log Folder
easyA file system keeps a log each time some user performs a change folder operation.
First Unique Character in a String
easyGiven a string s, find the first non-repeating character in it and return its index.
Number of Students Unable to Eat Lunch
easyThe school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively.
Time Needed to Buy Tickets
easyThere 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
easyYou are given an integer array prices where prices[i] is the price of the ith item in a shop.
Next Greater Element I
easyThe 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
mediumGiven 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
mediumYou are given a 0-indexed integer array nums.
Count Partitions With Max-Min Difference at Most K
mediumYou are given an integer array nums and an integer k.
Count Prime-Gap Balanced Subarrays
mediumYou are given an integer array nums and an integer k.
Week 2
Apple Redistribution into Boxes
easyYou are given an array apple of size n and an array capacity of size m.
Apply Operations to an Array
easyYou are given a 0-indexed array nums of size n consisting of non-negative integers.
Array Partition
easyGiven 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
easyYou have a bomb to defuse, and your time is running out!
Find the K-Beauty of a Number
easyThe 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
easyYou are given an array nums of n integers and two integers k and x.
Find Pivot Index
easyGiven an array of integers nums, calculate the pivot index of this array.
Find the Highest Altitude
easyThere is a biker going on a road trip.
Find the Middle Index in Array
easyGiven a 0-indexed integer array nums, find the leftmost middleIndex (i.e., the smallest amongst all the possible ones).
Make The String Great
easyGiven a string s of lower and upper case English letters.
Maximum Nesting Depth of the Parentheses
easyGiven a valid parentheses string s, return the nesting depth of s.
Minimum String Length After Removing Substrings
easyYou are given a string s consisting only of uppercase English letters.
Dota2 Senate
mediumIn the world of Dota2, there are two parties: the Radiant and the Dire.
Find the Winner of the Circular Game
mediumThere are n friends that are playing a game.
Jump Game VI
mediumYou are given a 0-indexed integer array nums and an integer k.
Beautiful Towers I
mediumYou are given an array heights of n integers representing the number of bricks in n consecutive towers.
Beautiful Towers II
mediumYou are given a 0-indexed array maxHeights of n integers.
Car Fleet
mediumThere 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
mediumGiven 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
mediumGiven 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
mediumYou 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
easyDetermine whether a singly-linked list loops back on itself instead of ending in null.
Merge Two Sorted Linked Lists
easySplice two sorted singly-linked lists together into a single sorted list.
Middle of the Linked List
easyFind the value stored in the middle node of a singly-linked list in a single pass.
Arranging Coins
easyYou have n coins and you want to build a staircase with these coins.
Binary Search
easyGiven 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
easyGiven an array arr of integers, check if there exist two indices i and j such that :
Delete Greatest Value in Each Row
easyYou are given an m x n matrix grid consisting of positive integers.
Final Array State After K Multiplication Operations I
easyYou are given an integer array nums, an integer k, and an integer multiplier.
Find Subsequence of Length K With the Largest Sum
easyYou are given an integer array nums and an integer k.
Assign Cookies
easyAssume you are an awesome parent and want to give your children some cookies.
Buy Two Chocolates
easyYou are given an integer array prices representing the prices of various chocolates in a store.
Can Place Flowers
easyYou have a long flowerbed in which some of the plots are planted, and some are not.
Count Prefix and Suffix Pairs I
easyYou are given a 0-indexed string array words.
Longest Common Prefix
easyWrite a function to find the longest common prefix string amongst an array of strings.
Maximum Strong Pair XOR I
easyYou are given a 0-indexed integer array nums.
Get All Root-to-Leaf Paths
easyReturn every root-to-leaf path in a binary tree as a list of node values, instead of an arrow-joined string.
Binary Tree Paths
easyReturn every root-to-leaf path in a binary tree as an arrow-joined string.
Binary Watch
easyA 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
easyGiven 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
easyCheck whether the values in a singly-linked list read the same forwards and backwards.
Remove Duplicates From a Sorted Linked List
easyCollapse consecutive duplicate values in a sorted singly-linked list so each value appears once.
Count Negative Numbers in a Sorted Matrix
easyGiven 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
easyYou are given a 0-indexed array of positive integers nums.
Fair Candy Swap
easyAlice and Bob have a different total number of candies.
Largest Number After Digit Swaps by Parity
easyYou are given a positive integer num.
Last Stone Weight
easyYou are given an array of integers stones where stones[i] is the weight of the ith stone.
Make Array Zero by Subtracting Equal Amounts
easyYou are given a non-negative integer array nums.
DI String Match
easyA 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
easyYou 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
easyThere is a bag that consists of items, each item has a number 1, 0, or -1 written on it.
Camelcase Matching
mediumGiven 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
mediumYou are given a 0-indexed string s and a dictionary of words dictionary.
Find the Length of the Longest Common Prefix
mediumYou are given two arrays with positive integers arr1 and arr2.
Sum of All Subset XOR Totals
easyThe XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty.
Additive Number
mediumAn additive number is a string whose digits can form an additive sequence.
All Paths From Source to Target
mediumGiven 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
easyAn 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
easyAdd 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
easyBuild a height-balanced binary search tree from an array sorted in ascending order.
Find if Path Exists in Graph
easyThere is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive).
Flood Fill
easyYou 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
easyYou 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
mediumGiven an m x n binary matrix mat, return the distance of the nearest 0 for each cell.
Accounts Merge
mediumGiven 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
mediumGiven 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
easyThere is an undirected star graph consisting of n nodes labeled from 1 to n.
Find the Town Judge
easyIn a town, there are n people labeled from 1 to n.
Cheapest Flights Within K Stops
mediumThere are n cities connected by some number of flights.
Course Schedule
mediumThere are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1.
Course Schedule II
mediumThere are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1.
Course Schedule IV
mediumThere 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
mediumYou are given an m x n grid.
Count Islands With Total Value Divisible by K
mediumYou are given an m x n matrix grid and a positive integer k.
Count Servers that Communicate
mediumYou 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
easyFlip a binary tree into its mirror image by swapping every node's left and right children.
Minimum Absolute Difference in a BST
easyFind the smallest absolute difference between the values of any two distinct nodes in a binary search tree.
Range Sum of a BST
easySum every node value in a binary search tree that falls within a given inclusive range.
Array Nesting
mediumYou 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
mediumGiven 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
mediumThere 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
mediumThere is a knight on an n x n chessboard.
Coin Change
mediumYou are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.
Coloring A Border
mediumYou are given an m x n integer matrix grid, and three integers row, col, and color.
Count the Number of Complete Components
mediumYou are given an integer n.
Count the Number of Houses at a Certain Distance I
mediumYou are given three positive integers n, x, and y.
Count Unreachable Pairs of Nodes in an Undirected Graph
mediumYou are given an integer n.
Find All Possible Recipes from Given Supplies
mediumYou have information about n different recipes.
Find Eventual Safe States
mediumThere is a directed graph of n nodes with each node labeled from 0 to n - 1.
Loud and Rich
mediumThere 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
mediumYou 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
mediumGiven 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
mediumYou 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
mediumYou are given two integers n and m that consist of the same number of digits.
Find a Safe Walk Through a Grid
mediumYou are given an m x n binary matrix grid and an integer health.
Find Minimum Time to Reach Last Room I
mediumThere is a dungeon with n x m rooms arranged as a grid.
Min Cost to Connect All Points
mediumYou 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
hardGiven 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
hardYou 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
hardThere is a safe protected by a password.
Critical Connections in a Network
hardThere 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
hardThere is an undirected tree with n nodes labeled from 0 to n - 1.
Best Time to Buy and Sell Stock
easyYou are given an array prices where prices[i] is the price of a given stock on the ith day.
Climbing Stairs
easyYou are climbing a staircase.
Counting Bits
easyGiven 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
easyYou 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
mediumThere are n soldiers standing in a line.
Fruits Into Baskets III
mediumYou 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
mediumYou 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
mediumYou 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
mediumGiven an integer array nums, return the number of longest increasing subsequences.
Week 8
Find Minimum Time to Reach Last Room II
mediumThere 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
mediumThere are n cities numbered from 0 to n-1.
Minimize the Maximum Edge Weight of Graph
mediumYou 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
hardYou are given an m x n binary grid grid where 1 represents land and 0 represents water.
Reconstruct Itinerary
hardYou 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
hardYou are given a 0-indexed 2D integer array pairs where pairs[i] = [starti, endi].
Divisor Game
easyAlice and Bob take turns playing a game, with Alice starting first.
Fibonacci Number
easyThe 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
easyGiven 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
mediumYou are given an array of strings words and a string target.
Queue Reconstruction by Height
mediumYou are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order).
Block Placement Queries
hardThere exists an infinite number line, with its origin at 0 and extending towards the positive x-axis.
Queries on a Permutation With Key
mediumGiven 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
hardThere are some red and blue tiles arranged circularly.
Count Good Triplets in an Array
hardYou are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1].