Practice
100 classic interview problems with instant tests in JavaScript, TypeScript and Python. Solve one alone, or share the room with a friend.
- 01Two SumFind the two numbers that add up to a target.ArraysHash mapEasy
- 02Valid ParenthesesCheck whether every bracket is closed in the right order.StringsStackEasy
- 03Valid AnagramDecide whether two words use exactly the same letters.StringsHash mapEasy
- 04Binary SearchFind a target in a sorted array in logarithmic time.ArraysBinary searchEasy
- 05Best Time to Buy and Sell StockPick one day to buy and a later day to sell for the biggest profit.ArraysGreedyEasy
- 06Valid PalindromeCheck whether a phrase reads the same both ways, ignoring punctuation.StringsTwo pointersEasy
- 07Climbing StairsCount the ways to climb a staircase one or two steps at a time.Dynamic programmingMathEasy
- 08Missing NumberFind the one number missing from a range.ArraysMathEasy
- 09First Unique CharacterFind the first character that appears only once.StringsHash mapEasy
- 10Roman to IntegerConvert a Roman numeral into a number.StringsMathEasy
- 11Single NumberEvery number appears twice except one. Find it.Bit manipulationArraysEasy
- 12Counting BitsCount the 1s in the binary form of every number up to n.Bit manipulationDynamic programmingEasy
- 13Move ZeroesShift every zero to the end while keeping the other numbers in order.ArraysTwo pointersEasy
- 14Reverse Linked ListReverse the direction of a singly linked list.Linked listEasy
- 15Merge Two Sorted ListsSplice two sorted linked lists into one sorted list.Linked listTwo pointersEasy
- 16Maximum Depth of Binary TreeMeasure how many levels deep a binary tree goes.TreesEasy
- 17Invert Binary TreeMirror a binary tree from left to right.TreesEasy
- 18Contains DuplicateCheck whether any number appears more than once.ArraysHash mapEasy
- 19Plus OneAdd one to a number stored as an array of digits.ArraysMathEasy
- 20Merge Sorted ArrayMerge one sorted array into another, in place.ArraysTwo pointersEasy
- 21Majority ElementFind the value that fills more than half the array.ArraysHash mapEasy
- 22Longest Common PrefixFind the longest start that every word shares.StringsEasy
- 23Fizz BuzzThe classic: Fizz for threes, Buzz for fives, FizzBuzz for both.MathStringsEasy
- 24Palindrome NumberCheck whether a number reads the same backward.MathEasy
- 25Reverse StringReverse an array of characters in place.StringsTwo pointersEasy
- 26Pascal's TriangleBuild the first rows of Pascal's triangle.ArraysDynamic programmingEasy
- 27Is SubsequenceCheck whether one string's letters appear, in order, inside another.StringsTwo pointersEasy
- 28Ransom NoteCheck whether one string can be built from another's letters.StringsHash mapEasy
- 29Squares of a Sorted ArraySquare every number of a sorted array and keep it sorted.ArraysTwo pointersEasy
- 30Middle of the Linked ListReturn the middle node of a linked list.Linked listTwo pointersEasy
- 31Same TreeCheck whether two binary trees are identical.TreesEasy
- 32Symmetric TreeCheck whether a binary tree is a mirror of itself.TreesQueueEasy
- 33Diameter of Binary TreeFind the longest path between any two nodes of a tree.TreesEasy
- 34Balanced Binary TreeCheck that no node's subtrees differ in height by more than one.TreesEasy
- 35Search Insert PositionFind where a value is, or where it would go, in a sorted array.ArraysBinary searchEasy
- 36Maximum SubarrayFind the contiguous run of numbers with the largest sum.ArraysDynamic programmingMedium
- 37Group AnagramsGroup together words that are anagrams of each other.StringsHash mapMedium
- 38Longest Substring Without RepeatsFind the longest stretch of text with no repeated character.StringsSliding windowMedium
- 39Product Except SelfMultiply everything except the current element, without division.ArraysPrefix sumsMedium
- 40Top K Frequent ElementsReturn the k numbers that appear most often.Hash mapHeapMedium
- 413SumFind every triplet of numbers that adds up to zero.ArraysTwo pointersMedium
- 42Container With Most WaterPick two walls that hold the most water between them.ArraysTwo pointersMedium
- 43Longest Consecutive SequenceFind the longest run of consecutive integers, in any order.ArraysHash mapMedium
- 44Subarray Sum Equals KCount the contiguous stretches that add up to k.ArraysPrefix sumsMedium
- 45Merge IntervalsCombine overlapping ranges into one sorted list.ArraysSortingMedium
- 46Insert IntervalAdd a new range to a sorted list of ranges, merging where needed.ArraysIntervalsMedium
- 47Search in Rotated Sorted ArrayBinary search in a sorted array that has been rotated.ArraysBinary searchMedium
- 48Daily TemperaturesFor each day, count how long until a warmer day arrives.ArraysStackMedium
- 49Kth Largest ElementFind the kth largest number without fully sorting.ArraysHeapMedium
- 50Coin ChangeMake an amount with as few coins as possible.Dynamic programmingMedium
- 51House RobberCollect the most money without ever taking from two neighbours.Dynamic programmingMedium
- 52Word BreakDecide whether a string can be split into dictionary words.StringsDynamic programmingMedium
- 53SubsetsList every possible subset of a set of numbers.BacktrackingBit manipulationMedium
- 54PermutationsList every ordering of a set of numbers.BacktrackingMedium
- 55Combination SumFind every combination that adds up to a target, reusing numbers freely.BacktrackingMedium
- 56Number of IslandsCount the groups of connected land on a map.GraphsMatrixMedium
- 57Rotting OrangesFind how many minutes it takes for rot to spread to every orange.GraphsMatrixMedium
- 58Course ScheduleDecide whether every course can be finished, given the prerequisites.GraphsMedium
- 59Connected ComponentsCount the separate groups in an undirected graph.GraphsUnion findMedium
- 60Rotate ImageTurn a square matrix 90 degrees clockwise, in place.MatrixArraysMedium
- 61Remove Nth Node From EndDelete the node that is n places from the end of a linked list.Linked listTwo pointersMedium
- 62Level Order TraversalRead a binary tree level by level, left to right.TreesQueueMedium
- 63Validate Binary Search TreeCheck whether a binary tree follows the search-tree ordering rule.TreesMedium
- 64Longest Palindromic SubstringFind the longest part of a string that reads the same backward.StringsDynamic programmingMedium
- 65Set Matrix ZeroesZero out the whole row and column of every 0, in place.MatrixArraysMedium
- 66Spiral MatrixRead a matrix in clockwise spiral order.MatrixArraysMedium
- 67Jump GameCan you hop from the first index to the last?ArraysGreedyMedium
- 68Unique PathsCount the paths across a grid moving only right or down.Dynamic programmingMathMedium
- 69Longest Increasing SubsequenceFind the length of the longest strictly increasing subsequence.Dynamic programmingBinary searchMedium
- 70Decode WaysCount the ways a string of digits can be read as letters.Dynamic programmingStringsMedium
- 71Find Minimum in Rotated Sorted ArrayFind the smallest value in a sorted array that was rotated.ArraysBinary searchMedium
- 72Generate ParenthesesList every valid combination of n pairs of parentheses.BacktrackingStringsMedium
- 73Letter Combinations of a Phone NumberList every word a string of phone digits could spell.BacktrackingStringsMedium
- 74Word SearchFind a word in a grid of letters by moving between neighbors.BacktrackingMatrixMedium
- 75Sort ColorsSort an array of 0s, 1s and 2s in a single pass.ArraysTwo pointersMedium
- 76Evaluate Reverse Polish NotationCompute an arithmetic expression written in postfix order.StackMathMedium
- 77Kth Smallest Element in a BSTFind the kth smallest value in a binary search tree.TreesStackMedium
- 78Binary Tree Right Side ViewList the nodes you'd see looking at a tree from the right.TreesQueueMedium
- 79Construct Binary Tree from Preorder and Inorder TraversalRebuild a binary tree from two of its traversals.TreesHash mapMedium
- 80Add Two NumbersAdd two numbers stored as linked lists of digits.Linked listMathMedium
- 81Network Delay TimeHow long until a signal reaches every node of a network?GraphsHeapMedium
- 82Trapping Rain WaterMeasure how much rain an elevation map can hold.ArraysTwo pointersHard
- 83Largest Rectangle in HistogramFind the biggest rectangle that fits under a bar chart.ArraysStackHard
- 84Sliding Window MaximumReport the largest number in every window of size k.Sliding windowQueueHard
- 85Minimum Window SubstringFind the shortest stretch of text containing every required letter.StringsSliding windowHard
- 86Median of Two Sorted ArraysFind the median of two sorted arrays combined.ArraysBinary searchHard
- 87Merge K Sorted ListsCombine any number of sorted linked lists into one.Linked listHeapHard
- 88Binary Tree Maximum Path SumFind the path through a tree whose values add up to the most.TreesDynamic programmingHard
- 89Word LadderFind the shortest chain of one-letter changes between two words.GraphsStringsHard
- 90N-QueensCount the ways to place n queens so that none attack each other.BacktrackingHard
- 91Edit DistanceCount the fewest edits that turn one word into another.StringsDynamic programmingHard
- 92Regular Expression MatchingMatch a string against a pattern with . and * wildcards.StringsDynamic programmingHard
- 93First Missing PositiveFind the smallest positive integer that's not in the array.ArraysHash mapHard
- 94Longest Valid ParenthesesFind the longest well-formed run of parentheses.StackDynamic programmingHard
- 95Burst BalloonsChoose the order to burst balloons for the most coins.Dynamic programmingHard
- 96Longest Increasing Path in a MatrixFind the longest strictly increasing walk through a grid.GraphsDynamic programmingHard
- 97Reverse Nodes in k-GroupReverse a linked list k nodes at a time.Linked listHard
- 98CandyGive out the fewest candies so that higher ratings get more.GreedyArraysHard
- 99Basic CalculatorEvaluate an expression with +, -, parentheses and spaces.StackMathHard
- 100Maximal RectangleFind the largest rectangle made only of 1s in a grid.StackDynamic programmingHard
100 problems