Sulba
000 / 100

The NeetCode 150 · learn it by watching it run

Every problem,running in front of you.

150 problems, each restated in plain words, solved in 6 languages, and drawn step by step as the algorithm runs on its example.

Contains Duplicate · O(n) time18 patterns771 test cases · 6 languages
Problems
150
Patterns
18
Languages
6
Test cases run
771
0/150

Your progress

Open any problem to begin, and mark it understood when the idea clicks.

Easy0/28
Medium0/101
Hard0/21

18 · Patterns

Patterns

Each pattern is one idea that cracks a family of problems. Learn the idea once; use it everywhere it applies.

  1. 01Arrays & HashingTrade memory for time: a hash map answers “have I seen this?” in one step instead of a search.9 problems
  2. 02Two PointersTwo indices walking toward each other (or together) through ordered data, each step ruling out a whole row of possibilities.5 problems
  3. 03Sliding WindowA stretch of the array that grows at one end and shrinks at the other, so every contiguous stretch is considered without starting over.6 problems
  4. 04StackLast in, first out: keep the things still waiting to be matched or resolved, and deal with the newest first.7 problems
  5. 05Binary SearchHalve the possibilities with every question: whenever the answer lies on one side of a line you can test, log n steps find it.7 problems
  6. 06Linked ListNodes that know only the next one: every trick is about which arrows to redirect, in what order, without losing the rest of the chain.11 problems
  7. 07TreesA tree is a node and two smaller trees. Solve it for one node, trust the same function on the children, and the whole tree is solved.15 problems
  8. 08TriesStore words letter by letter down a tree, so every word sharing a beginning shares the path — and a prefix is found in as many steps as it has letters.3 problems
  9. 09Heap / Priority QueueA heap always knows its smallest (or largest) item, and adding or removing one costs only log n — the tool for “the best k” and “what comes next”.7 problems
  10. 10BacktrackingBuild an answer one choice at a time; when a choice leads nowhere, undo it and try the next. Every answer is a path through a tree of choices.9 problems
  11. 11GraphsThings joined to things — cells on a map, courses by their prerequisites, words by one letter. Depth-first goes deep along one path; breadth-first spreads out one ring at a time.13 problems
  12. 12Advanced GraphsWeighted edges and ordering constraints: shortest paths with Dijkstra and Bellman–Ford, the cheapest network with Prim, and a route that uses every edge once.6 problems
  13. 131-D Dynamic ProgrammingWhen the answer for n is built from answers for smaller n, compute each one once and keep it. A row of remembered answers, filled in order.12 problems
  14. 142-D Dynamic ProgrammingTwo things change at once — a position in each of two strings, a row and a column, an index and an amount — so the remembered answers form a table.11 problems
  15. 15GreedyMake the choice that looks best right now and never revisit it — correct only when you can argue no later step would ever want it undone.8 problems
  16. 16IntervalsStretches of a line, from a start to an end. Sort them by one end, and overlaps become a question about neighbours.6 problems
  17. 17Math & GeometryA little arithmetic or a picture of the grid turns a fiddly simulation into a few lines: rotations as flips, powers by squaring, digits by place value.8 problems
  18. 18Bit ManipulationNumbers are rows of 0s and 1s, and a handful of operations — AND, OR, XOR, shifts — work on every bit at once.7 problems

150 · All problems

All problems

Filter by pattern, difficulty or where you are with it.

  1. 217Contains DuplicateArrays & HashingEasyNot started
  2. 242Valid AnagramArrays & HashingEasyNot started
  3. 1Two SumArrays & HashingEasyNot started
  4. 49Group AnagramsArrays & HashingMediumNot started
  5. 347Top K Frequent ElementsArrays & HashingMediumNot started
  6. 238Product of Array Except SelfArrays & HashingMediumNot started
  7. 36Valid SudokuArrays & HashingMediumNot started
  8. 271Encode and Decode StringsArrays & HashingMediumNot started
  9. 128Longest Consecutive SequenceArrays & HashingMediumNot started
  10. 125Valid PalindromeTwo PointersEasyNot started
  11. 167Two Sum II – Input Array Is SortedTwo PointersMediumNot started
  12. 153SumTwo PointersMediumNot started
  13. 11Container With Most WaterTwo PointersMediumNot started
  14. 42Trapping Rain WaterTwo PointersHardNot started
  15. 121Best Time to Buy and Sell StockSliding WindowEasyNot started
  16. 3Longest Substring Without Repeating CharactersSliding WindowMediumNot started
  17. 424Longest Repeating Character ReplacementSliding WindowMediumNot started
  18. 567Permutation in StringSliding WindowMediumNot started
  19. 76Minimum Window SubstringSliding WindowHardNot started
  20. 239Sliding Window MaximumSliding WindowHardNot started
  21. 20Valid ParenthesesStackEasyNot started
  22. 155Min StackStackMediumNot started
  23. 150Evaluate Reverse Polish NotationStackMediumNot started
  24. 22Generate ParenthesesStackMediumNot started
  25. 739Daily TemperaturesStackMediumNot started
  26. 853Car FleetStackMediumNot started
  27. 84Largest Rectangle in HistogramStackHardNot started
  28. 704Binary SearchBinary SearchEasyNot started
  29. 74Search a 2D MatrixBinary SearchMediumNot started
  30. 875Koko Eating BananasBinary SearchMediumNot started
  31. 153Find Minimum in Rotated Sorted ArrayBinary SearchMediumNot started
  32. 33Search in Rotated Sorted ArrayBinary SearchMediumNot started
  33. 981Time Based Key-Value StoreBinary SearchMediumNot started
  34. 4Median of Two Sorted ArraysBinary SearchHardNot started
  35. 206Reverse Linked ListLinked ListEasyNot started
  36. 21Merge Two Sorted ListsLinked ListEasyNot started
  37. 143Reorder ListLinked ListMediumNot started
  38. 19Remove Nth Node From End of ListLinked ListMediumNot started
  39. 138Copy List with Random PointerLinked ListMediumNot started
  40. 2Add Two NumbersLinked ListMediumNot started
  41. 141Linked List CycleLinked ListEasyNot started
  42. 287Find the Duplicate NumberLinked ListMediumNot started
  43. 146LRU CacheLinked ListMediumNot started
  44. 23Merge k Sorted ListsLinked ListHardNot started
  45. 25Reverse Nodes in k-GroupLinked ListHardNot started
  46. 226Invert Binary TreeTreesEasyNot started
  47. 104Maximum Depth of Binary TreeTreesEasyNot started
  48. 543Diameter of Binary TreeTreesEasyNot started
  49. 110Balanced Binary TreeTreesEasyNot started
  50. 100Same TreeTreesEasyNot started
  51. 572Subtree of Another TreeTreesEasyNot started
  52. 235Lowest Common Ancestor of a Binary Search TreeTreesMediumNot started
  53. 102Binary Tree Level Order TraversalTreesMediumNot started
  54. 199Binary Tree Right Side ViewTreesMediumNot started
  55. 1448Count Good Nodes in Binary TreeTreesMediumNot started
  56. 98Validate Binary Search TreeTreesMediumNot started
  57. 230Kth Smallest Element in a BSTTreesMediumNot started
  58. 105Construct Binary Tree from Preorder and Inorder TraversalTreesMediumNot started
  59. 124Binary Tree Maximum Path SumTreesHardNot started
  60. 297Serialize and Deserialize Binary TreeTreesHardNot started
  61. 208Implement Trie (Prefix Tree)TriesMediumNot started
  62. 211Design Add and Search Words Data StructureTriesMediumNot started
  63. 212Word Search IITriesHardNot started
  64. 703Kth Largest Element in a StreamHeap / Priority QueueEasyNot started
  65. 1046Last Stone WeightHeap / Priority QueueEasyNot started
  66. 973K Closest Points to OriginHeap / Priority QueueMediumNot started
  67. 215Kth Largest Element in an ArrayHeap / Priority QueueMediumNot started
  68. 621Task SchedulerHeap / Priority QueueMediumNot started
  69. 355Design TwitterHeap / Priority QueueMediumNot started
  70. 295Find Median from Data StreamHeap / Priority QueueHardNot started
  71. 78SubsetsBacktrackingMediumNot started
  72. 39Combination SumBacktrackingMediumNot started
  73. 46PermutationsBacktrackingMediumNot started
  74. 90Subsets IIBacktrackingMediumNot started
  75. 40Combination Sum IIBacktrackingMediumNot started
  76. 79Word SearchBacktrackingMediumNot started
  77. 131Palindrome PartitioningBacktrackingMediumNot started
  78. 17Letter Combinations of a Phone NumberBacktrackingMediumNot started
  79. 51N-QueensBacktrackingHardNot started
  80. 200Number of IslandsGraphsMediumNot started
  81. 133Clone GraphGraphsMediumNot started
  82. 695Max Area of IslandGraphsMediumNot started
  83. 417Pacific Atlantic Water FlowGraphsMediumNot started
  84. 130Surrounded RegionsGraphsMediumNot started
  85. 994Rotting OrangesGraphsMediumNot started
  86. 286Walls and GatesGraphsMediumNot started
  87. 207Course ScheduleGraphsMediumNot started
  88. 210Course Schedule IIGraphsMediumNot started
  89. 684Redundant ConnectionGraphsMediumNot started
  90. 323Number of Connected Components in an Undirected GraphGraphsMediumNot started
  91. 261Graph Valid TreeGraphsMediumNot started
  92. 127Word LadderGraphsHardNot started
  93. 332Reconstruct ItineraryAdvanced GraphsHardNot started
  94. 1584Min Cost to Connect All PointsAdvanced GraphsMediumNot started
  95. 743Network Delay TimeAdvanced GraphsMediumNot started
  96. 778Swim in Rising WaterAdvanced GraphsHardNot started
  97. 269Alien DictionaryAdvanced GraphsHardNot started
  98. 787Cheapest Flights Within K StopsAdvanced GraphsMediumNot started
  99. 70Climbing Stairs1-D Dynamic ProgrammingEasyNot started
  100. 746Min Cost Climbing Stairs1-D Dynamic ProgrammingEasyNot started
  101. 198House Robber1-D Dynamic ProgrammingMediumNot started
  102. 213House Robber II1-D Dynamic ProgrammingMediumNot started
  103. 5Longest Palindromic Substring1-D Dynamic ProgrammingMediumNot started
  104. 647Palindromic Substrings1-D Dynamic ProgrammingMediumNot started
  105. 91Decode Ways1-D Dynamic ProgrammingMediumNot started
  106. 322Coin Change1-D Dynamic ProgrammingMediumNot started
  107. 152Maximum Product Subarray1-D Dynamic ProgrammingMediumNot started
  108. 139Word Break1-D Dynamic ProgrammingMediumNot started
  109. 300Longest Increasing Subsequence1-D Dynamic ProgrammingMediumNot started
  110. 416Partition Equal Subset Sum1-D Dynamic ProgrammingMediumNot started
  111. 62Unique Paths2-D Dynamic ProgrammingMediumNot started
  112. 1143Longest Common Subsequence2-D Dynamic ProgrammingMediumNot started
  113. 309Best Time to Buy and Sell Stock with Cooldown2-D Dynamic ProgrammingMediumNot started
  114. 518Coin Change II2-D Dynamic ProgrammingMediumNot started
  115. 494Target Sum2-D Dynamic ProgrammingMediumNot started
  116. 97Interleaving String2-D Dynamic ProgrammingMediumNot started
  117. 329Longest Increasing Path in a Matrix2-D Dynamic ProgrammingHardNot started
  118. 115Distinct Subsequences2-D Dynamic ProgrammingHardNot started
  119. 72Edit Distance2-D Dynamic ProgrammingMediumNot started
  120. 312Burst Balloons2-D Dynamic ProgrammingHardNot started
  121. 10Regular Expression Matching2-D Dynamic ProgrammingHardNot started
  122. 53Maximum SubarrayGreedyMediumNot started
  123. 55Jump GameGreedyMediumNot started
  124. 45Jump Game IIGreedyMediumNot started
  125. 134Gas StationGreedyMediumNot started
  126. 846Hand of StraightsGreedyMediumNot started
  127. 1899Merge Triplets to Form Target TripletGreedyMediumNot started
  128. 763Partition LabelsGreedyMediumNot started
  129. 678Valid Parenthesis StringGreedyMediumNot started
  130. 57Insert IntervalIntervalsMediumNot started
  131. 56Merge IntervalsIntervalsMediumNot started
  132. 435Non-overlapping IntervalsIntervalsMediumNot started
  133. 252Meeting RoomsIntervalsEasyNot started
  134. 253Meeting Rooms IIIntervalsMediumNot started
  135. 1851Minimum Interval to Include Each QueryIntervalsHardNot started
  136. 48Rotate ImageMath & GeometryMediumNot started
  137. 54Spiral MatrixMath & GeometryMediumNot started
  138. 73Set Matrix ZeroesMath & GeometryMediumNot started
  139. 202Happy NumberMath & GeometryEasyNot started
  140. 66Plus OneMath & GeometryEasyNot started
  141. 50Pow(x, n)Math & GeometryMediumNot started
  142. 43Multiply StringsMath & GeometryMediumNot started
  143. 2013Detect SquaresMath & GeometryMediumNot started
  144. 136Single NumberBit ManipulationEasyNot started
  145. 191Number of 1 BitsBit ManipulationEasyNot started
  146. 338Counting BitsBit ManipulationEasyNot started
  147. 190Reverse BitsBit ManipulationEasyNot started
  148. 268Missing NumberBit ManipulationEasyNot started
  149. 371Sum of Two IntegersBit ManipulationMediumNot started
  150. 7Reverse IntegerBit ManipulationMediumNot started
Showing 150 of 150