Practice
Solve problems in your browser
Every problem starts as a small story, gives you hints one at a time, and runs your JavaScript or Python against real tests. Nothing to install.
Arrays & Hashing
16 problemsCounting, lookups and remembering what you have seen. Learn it first: Arrays, Strings, Hash Tables, Prefix Sums.
- Matching ReceiptsTwo Sumhash mapEasy
- Double-Scanned TicketsContains Duplicatehash mapEasy
- Same Letter TilesValid Anagramhash mapEasy
- The Missing Exam PaperMissing NumbermathEasy
- One-of-a-Kind BeadFirst Unique Character in a Stringhash mapEasy
- Circling the GarageContains Duplicate IIhash mapEasy
- Field Trip VoteMajority Elementhash mapEasy
- Comic Book FlipBest Time to Buy and Sell StockgreedyEasy
- Split the Night MarketFind Pivot Indexprefix sumsEasy
- Rotating Chore ChartRotate Arraytwo pointersMedium
- Jumble Puzzle BinsGroup Anagramshash mapMedium
- Bakery BestsellersTop K Frequent Elementshash mapMedium
- Power-Up MultipliersProduct of Array Except Selfprefix sumsMedium
- No-Repeat Garden BedsValid Sudokuhash mapMedium
- Longest Reading StreakLongest Consecutive Sequencehash mapHard
- Net Climb StretchesSubarray Sum Equals Kprefix sumsHard
Two Pointers & Sliding Window
13 problemsWalk an array from both ends, or keep a moving window. Learn it first: Two Pointers, Sliding Window.
- Squared DeviationsSquares of a Sorted Arraytwo pointersEasy
- Mirror Phrase ContestValid Palindrometwo pointersEasy
- Merged Departure BoardRemove Duplicates from Sorted Arraytwo pointersEasy
- Bakery Tray GapsMove Zeroestwo pointersEasy
- Food Truck Best StretchMaximum Sum Subarray of Size Ksliding windowEasy
- Backdrop Between PolesContainer With Most Watertwo pointersMedium
- Neutral Charge Trios3Sumtwo pointersMedium
- Sushi Belt Without RepeatsLongest Substring Without Repeating Characterssliding windowMedium
- Shortest Steep ClimbMinimum Size Subarray Sumsliding windowMedium
- Adjacent Spice JarsPermutation in Stringsliding windowMedium
- Repaint the FenceLongest Repeating Character Replacementsliding windowMedium
- Market Street ErrandMinimum Window Substringsliding windowHard
- Rain on Brick TowersTrapping Rain Watertwo pointersHard
Linked Lists, Stacks & Queues
13 problemsPointer surgery and last-in, first-out thinking. Learn it first: Linked Lists, Stacks, Queues and Deques, Monotonic Stack.
- Reverse the PlaylistReverse Linked Listpointer reversalEasy
- Nesting Gift BoxesValid ParenthesesstackEasy
- Middle of the ParadeMiddle of the Linked Listtwo pointersEasy
- One Van, Two RoutesMerge Two Sorted Liststwo pointersEasy
- Vintage Calculator TapeEvaluate Reverse Polish NotationstackEasy
- Two-Spike Order RailImplement Queue using StacksdesignEasy
- Lowest Point on the TrailMin StackdesignMedium
- Closed Tram StopRemove Nth Node From End of Listtwo pointersMedium
- Symmetric Bead StrandPalindrome Linked Listtwo pointersMedium
- Stadium Gate TalliesAdd Two NumbersmathMedium
- Waiting for a Bigger WaveDaily Temperaturesmonotonic stackMedium
- Freezer Warmest StretchSliding Window MaximumqueueHard
- Mural on the Stepped WallLargest Rectangle in Histogrammonotonic stackHard
Binary Search & Sorting
12 problemsHalve the search space, or sort first and make the problem easy. Learn it first: Simple Sorts, Merge Sort, Quicksort, Heap Sort.
- Raffle Stub LookupBinary Searchbinary searchEasy
- New Dish on the MenuSearch Insert Positionbinary searchEasy
- Square Patio TilesSqrt(x)binary searchEasy
- Two-Heat Results BoardMerge Sorted Arraytwo pointersEasy
- Warehouse Bin GridSearch a 2D Matrixbinary searchEasy
- Postcode Stretch on the VanFind First and Last Position of Element in Sorted Arraybinary searchMedium
- Night Guard RoundSearch in Rotated Sorted Arraybinary searchMedium
- Photo Contest PodiumKth Largest Element in an ArraysortingMedium
- Biggest Number From CardsLargest NumbersortingMedium
- Book Club Reading PlanCapacity To Ship Packages Within D Daysbinary searchMedium
- How Messy Is the ShelfCount InversionssortingHard
- Two-Station MedianMedian of Two Sorted Arraysbinary searchHard
Trees
13 problemsRecursion on trees, traversals and search trees. Learn it first: Binary Trees, Tree Traversals, Binary Search Trees, Balanced Trees.
- Generation AveragesAverage of Levels in Binary Treebreadth-first searchEasy
- How Deep the Cave GoesMaximum Depth of Binary Treedepth-first searchEasy
- Matching Phone MenusSame Treedepth-first searchEasy
- Iron-On Transfer FlipInvert Binary Treedepth-first searchEasy
- Will the Mobile Hang StraightSymmetric Treedepth-first searchEasy
- Adventure Book GoldPath Sumdepth-first searchEasy
- Acrobats From the WingsBinary Tree Right Side Viewbreadth-first searchMedium
- Longest Museum StrollDiameter of Binary Treedepth-first searchMedium
- Library Index AuditValidate Binary Search Treedepth-first searchMedium
- K-th Fastest FinisherKth Smallest Element in a BSTdepth-first searchMedium
- Closest Shared MentorLowest Common Ancestor of a Binary Treedepth-first searchMedium
- Rebuild the Escape Room CluesConstruct Binary Tree from Preorder and Inorder TraversalrecursionMedium
- Vineyard Tasting RouteBinary Tree Maximum Path Sumdepth-first searchHard
Graphs
12 problemsGrids, networks, dependencies and shortest paths. Learn it first: Graph Basics, Breadth-First Search, Depth-First Search, Topological Sort.
- Recolor the Cross-StitchFlood Filldepth-first searchEasy
- Parking Lot PuddlesNumber of Islandsdepth-first searchEasy
- Corn Maze ShortcutShortest Path in a Mazebreadth-first searchEasy
- Loose Pieces on the TableNumber of Connected Components in an Undirected Graphunion-findEasy
- Two Buses for the TripIs Graph Bipartite?breadth-first searchEasy
- Aphids in the GreenhouseRotting Orangesbreadth-first searchMedium
- One Cable Too ManyRedundant Connectionunion-findMedium
- Flat-Pack Assembly OrderCourse Schedule IItopological sortMedium
- Staff Alert RelayNetwork Delay Timeshortest pathMedium
- Wiring the CampsitesMin Cost to Connect All PointsgreedyMedium
- Parcel With Few HandoffsCheapest Flights Within K Stopsshortest pathHard
- Marquee Letter SwapsWord Ladderbreadth-first searchHard
Backtracking & Recursion
11 problemsTry a choice, explore, undo, try the next. Learn it first: Recursion, Backtracking, Divide and Conquer.
- Moving the Wedding CakeTower of HanoirecursionEasy
- Rabbit Counter WraparoundPow(x, n) / Modular ExponentiationrecursionEasy
- Burger Truck Test OrdersSubsetsbacktrackingEasy
- Relay Practice LineupsPermutationsbacktrackingEasy
- Postcard Mountain SkylinesGenerate ParenthesesbacktrackingMedium
- Exact Postage StampsCombination SumbacktrackingMedium
- Smudged Router LabelRestore IP AddressesbacktrackingMedium
- Café Letter BoardWord SearchbacktrackingMedium
- Festival Train SplitPalindrome PartitioningbacktrackingMedium
- Gallery Ceiling SensorsN-Queens IIbacktrackingHard
- Puzzle Page Mini GridSudoku Solver (6 × 6)backtrackingHard
Greedy & Intervals
11 problemsMake the locally best move, and know when that is safe. Learn it first: Greedy Algorithms, Intervals.
- Coat Drive HandoutAssign CookiesgreedyEasy
- Ferry Fare ChangeLemonade ChangegreedyEasy
- Resurfaced Road StretchesMerge IntervalsintervalsEasy
- Relay Towers Down the ValleyJump GamegreedyEasy
- Studio Booking SheetInsert IntervalintervalsMedium
- Parcel Line Into TrucksPartition LabelsgreedyMedium
- Shared Telescope NightNon-overlapping IntervalsintervalsMedium
- Laundromat Machine CountMeeting Rooms IIintervalsMedium
- Hut-to-Hut TrekJump Game IIgreedyMedium
- Ring Line Tram BatteryGas StationgreedyHard
- Gym Sets With RestTask SchedulergreedyHard
Dynamic Programming
14 problemsDefine the subproblem, then fill the table. Learn it first: Introduction to Dynamic Programming, 1D Dynamic Programming, DP on Grids, Knapsack.
- Stepping Stones Across the PondClimbing Stairsdynamic programmingEasy
- Sunny Orchard RowHouse Robberdynamic programmingEasy
- Arcade Tile RunMaximum Subarray (Kadane's Algorithm)dynamic programmingEasy
- Roadworks on the GridUnique Paths IIdynamic programmingEasy
- Snowplow to the RoadMinimum Path Sumdynamic programmingEasy
- Cookie Box OrderCoin Change (fewest coins)dynamic programmingMedium
- Vending Machine Coin MixesCoin Change II (number of combinations)dynamic programmingMedium
- Secret Number NotesDecode Waysdynamic programmingMedium
- Squashed HashtagWord Breakdynamic programmingMedium
- Typing Class ProgressLongest Increasing Subsequencedynamic programmingMedium
- Shared Dance MovesLongest Common Subsequencedynamic programmingMedium
- Busking Set List0/1 Knapsackdynamic programmingMedium
- Sneaker Resale With a Shipping DayBest Time to Buy and Sell Stock with Cooldowndynamic programmingHard
- Spelling Test FixesEdit Distance (Levenshtein Distance)dynamic programmingHard
Heaps, Tries & Bits
12 problemsSpecialised structures and low-level tricks. Learn it first: Heaps and Priority Queues, Tries, Bit Manipulation, String Matching.
- Knockout Bracket CheckPower of Twobit manipulationEasy
- Last Car in the GarageSingle Numberbit manipulationEasy
- Binary Counter ExhibitCounting Bitsbit manipulationEasy
- Upside-Down Light StripReverse Bitsbit manipulationEasy
- Snowball ShowdownLast Stone WeightheapEasy
- Quiz League Final CutoffKth Largest Element in a StreamheapMedium
- Drone Nearest Drop-OffsK Closest Points to OriginheapMedium
- Glowing Letter TilesImplement Trie (Prefix Tree)trieMedium
- Town Baby Name ChartTop K Frequent WordsheapMedium
- Garden Centre Plant FinderSearch Suggestions SystemtrieMedium
- Wedding Camera TimelineMerge k Sorted ListsheapHard
- Live Median House PriceFind Median from Data StreamheapHard
ML From Scratch
11 problemsBuild the core pieces of machine learning with plain code. Learn it first: How Models Learn, Regression and Classification, Overfitting and Evaluation, Decision Trees and Ensembles.
- Ice Cream Forecast CheckMean Squared ErrormathEasy
- Bookshop Blurb MatchCosine Similaritylinear algebraEasy
- Trail Guide SnippetsOverlapping Text Chunkingsliding windowEasy
- Bruised Apple DetectorPrecision, Recall and F1 ScoremathEasy
- Delivery Time NudgeOne Step of Gradient Descent for Linear Regressiongradient descentEasy
- Storyteller Word OddsSoftmax with TemperatureprobabilityMedium
- Unlabelled Seed Packetk-Nearest Neighbours ClassificationsortingMedium
- Pronoun Looks BackScaled Dot-Product Attention Weightslinear algebraMedium
- Sign Shop Letter BlocksGreedy Longest-Match TokenizergreedyMedium
- Festival Charging Cartsk-Means ClusteringsimulationMedium
- Knitting Pattern ShorthandByte Pair Encoding (BPE) Mergeshash mapHard