Skip to content
LEETFLIX

type

Stack LeetCode problems — visual solutions

Every LeetCode problem tagged Stack — the full catalogue, plus animated visual solutions in Python and Go when a deep-dive exists.

182 problems · 150 animated · 32 locked

Start with a walkthrough

Full Stack index

  1. 20Valid ParenthesesWatch
  2. 32Longest Valid ParenthesesWatch
  3. 42Trapping Rain WaterWatch
  4. 71Simplify PathWatch
  5. 84Largest Rectangle in HistogramWatch
  6. 85Maximal RectangleWatch
  7. 94Binary Tree Inorder TraversalWatch
  8. 114Flatten Binary Tree to Linked ListWatch
  9. 143Reorder ListWatch
  10. 144Binary Tree Preorder TraversalWatch
  11. 145Binary Tree Postorder TraversalWatch
  12. 150Evaluate Reverse Polish NotationWatch
  13. 155Min StackWatch
  14. 173Binary Search Tree IteratorWatch
  15. 224Basic CalculatorWatch
  16. 225Implement Stack using QueuesWatch
  17. 227Basic Calculator IIWatch
  18. 232Implement Queue using StacksWatch
  19. 234Palindrome Linked ListWatch
  20. 255Verify Preorder Sequence in Binary Search TreeLocked
  21. 272Closest Binary Search Tree Value IILocked
  22. 316Remove Duplicate LettersWatch
  23. 321Create Maximum NumberWatch
  24. 331Verify Preorder Serialization of a Binary TreeWatch
  25. 341Flatten Nested List IteratorWatch
  26. 364Nested List Weight Sum IILocked
  27. 385Mini ParserWatch
  28. 388Longest Absolute File PathWatch
  29. 394Decode StringWatch
  30. 402Remove K DigitsWatch
  31. 426Convert Binary Search Tree to Sorted Doubly Linked ListLocked
  32. 439Ternary Expression ParserLocked
  33. 445Add Two Numbers IIWatch
  34. 456132 PatternWatch
  35. 484Find PermutationLocked
  36. 488Zuma GameWatch
  37. 496Next Greater Element IWatch
  38. 503Next Greater Element IIWatch
  39. 536Construct Binary Tree from StringLocked
  40. 581Shortest Unsorted Continuous SubarrayWatch
  41. 589N-ary Tree Preorder TraversalWatch
  42. 590N-ary Tree Postorder TraversalWatch
  43. 591Tag ValidatorWatch
  44. 636Exclusive Time of FunctionsWatch
  45. 654Maximum Binary TreeWatch
  46. 678Valid Parenthesis StringWatch
  47. 682Baseball GameWatch
  48. 716Max StackLocked
  49. 726Number of AtomsWatch
  50. 735Asteroid CollisionWatch
  51. 736Parse Lisp ExpressionWatch
  52. 739Daily TemperaturesWatch
  53. 768Max Chunks To Make Sorted IIWatch
  54. 769Max Chunks To Make SortedWatch
  55. 770Basic Calculator IVWatch
  56. 772Basic Calculator IIILocked
  57. 844Backspace String CompareWatch
  58. 853Car FleetWatch
  59. 856Score of ParenthesesWatch
  60. 880Decoded String at IndexWatch
  61. 895Maximum Frequency StackWatch
  62. 897Increasing Order Search TreeWatch
  63. 901Online Stock SpanWatch
  64. 907Sum of Subarray MinimumsWatch
  65. 921Minimum Add to Make Parentheses ValidWatch
  66. 936Stamping The SequenceWatch
  67. 946Validate Stack SequencesWatch
  68. 962Maximum Width RampWatch
  69. 975Odd Even JumpWatch
  70. 1003Check If Word Is Valid After SubstitutionsWatch
  71. 1006Clumsy FactorialWatch
  72. 1008Construct Binary Search Tree from Preorder TraversalWatch
  73. 1019Next Greater Node In Linked ListWatch
  74. 1021Remove Outermost ParenthesesWatch
  75. 1047Remove All Adjacent Duplicates In StringWatch
  76. 1063Number of Valid SubarraysLocked
  77. 1081Smallest Subsequence of Distinct CharactersWatch
  78. 1087Brace ExpansionLocked
  79. 1096Brace Expansion IIWatch
  80. 1106Parsing A Boolean ExpressionWatch
  81. 1111Maximum Nesting Depth of Two Valid Parentheses StringsWatch
  82. 1124Longest Well-Performing IntervalWatch
  83. 1130Minimum Cost Tree From Leaf ValuesWatch
  84. 1172Dinner Plate StacksWatch
  85. 1190Reverse Substrings Between Each Pair of ParenthesesWatch
  86. 1209Remove All Adjacent Duplicates in String IIWatch
  87. 1214Two Sum BSTsLocked
  88. 1249Minimum Remove to Make Valid ParenthesesWatch
  89. 1265Print Immutable Linked List in ReverseLocked
  90. 1381Design a Stack With Increment OperationWatch
  91. 1441Build an Array With Stack OperationsWatch
  92. 1472Design Browser HistoryWatch
  93. 1475Final Prices With a Special Discount in a ShopWatch
  94. 1504Count Submatrices With All OnesWatch
  95. 1526Minimum Number of Increments on Subarrays to Form a Target ArrayWatch
  96. 1541Minimum Insertions to Balance a Parentheses StringWatch
  97. 1544Make The String GreatWatch
  98. 1574Shortest Subarray to be Removed to Make Array SortedWatch
  99. 1586Binary Search Tree Iterator IILocked
  100. 1597Build Binary Expression Tree From Infix ExpressionLocked
  101. 1598Crawler Log FolderWatch
  102. 1614Maximum Nesting Depth of the ParenthesesWatch
  103. 1628Design an Expression Tree With Evaluate FunctionLocked
  104. 1653Minimum Deletions to Make String BalancedWatch
  105. 1673Find the Most Competitive SubsequenceWatch
  106. 1700Number of Students Unable to Eat LunchWatch
  107. 1717Maximum Score From Removing SubstringsWatch
  108. 1762Buildings With an Ocean ViewLocked
  109. 1776Car Fleet IIWatch
  110. 1793Maximum Score of a Good SubarrayWatch
  111. 1856Maximum Subarray Min-ProductWatch
  112. 1896Minimum Cost to Change the Final Value of ExpressionWatch
  113. 1910Remove All Occurrences of a SubstringWatch
  114. 1944Number of Visible People in a QueueWatch
  115. 1950Maximum of Minimum Values in All SubarraysLocked
  116. 1963Minimum Number of Swaps to Make the String BalancedWatch
  117. 1966Binary Searchable Numbers in an Unsorted ArrayLocked
  118. 1996The Number of Weak Characters in the GameWatch
  119. 2000Reverse Prefix of WordWatch
  120. 2019The Score of Students Solving Math ExpressionWatch
  121. 2030Smallest K-Length Subsequence With Occurrences of a LetterWatch
  122. 2104Sum of Subarray RangesWatch
  123. 2116Check if a Parentheses String Can Be ValidWatch
  124. 2130Maximum Twin Sum of a Linked ListWatch
  125. 2197Replace Non-Coprime Numbers in ArrayWatch
  126. 2211Count Collisions on a RoadWatch
  127. 2216Minimum Deletions to Make Array BeautifulWatch
  128. 2281Sum of Total Strength of WizardsWatch
  129. 2282Number of People That Can Be Seen in a GridLocked
  130. 2289Steps to Make Array Non-decreasingWatch
  131. 2296Design a Text EditorWatch
  132. 2297Jump Game VIIILocked
  133. 2334Subarray With Elements Greater Than Varying ThresholdWatch
  134. 2345Finding the Number of Visible MountainsLocked
  135. 2355Maximum Number of Books You Can TakeLocked
  136. 2375Construct Smallest Number From DI StringWatch
  137. 2390Removing Stars From a StringWatch
  138. 2434Using a Robot to Print the Lexicographically Smallest StringWatch
  139. 2454Next Greater Element IVWatch
  140. 2487Remove Nodes From Linked ListWatch
  141. 2524Maximum Frequency Score of a SubarrayLocked
  142. 2589Minimum Time to Complete All TasksWatch
  143. 2617Minimum Number of Visited Cells in a GridWatch
  144. 2645Minimum Additions to Make Valid StringWatch
  145. 2696Minimum String Length After Removing SubstringsWatch
  146. 2736Maximum Sum QueriesWatch
  147. 2751Robot CollisionsWatch
  148. 2764Is Array a Preorder of Some ‌Binary TreeLocked
  149. 2813Maximum Elegance of a K-Length SubsequenceWatch
  150. 2816Double a Number Represented as a Linked ListWatch
  151. 2818Apply Operations to Maximize ScoreWatch
  152. 2832Maximal Range That Each Element Is Maximum in ItLocked
  153. 2863Maximum Length of Semi-Decreasing SubarraysLocked
  154. 2865Beautiful Towers IWatch
  155. 2866Beautiful Towers IIWatch
  156. 2940Find Building Where Alice and Bob Can MeetWatch
  157. 2945Find Maximum Non-decreasing Array LengthWatch
  158. 3113Find the Number of Subarrays Where Boundary Elements Are MaximumWatch
  159. 3170Lexicographically Minimum String After Removing StarsWatch
  160. 3174Clear DigitsWatch
  161. 3205Maximum Array Hopping Score ILocked
  162. 3221Maximum Array Hopping Score IILocked
  163. 3229Minimum Operations to Make Array Equal to TargetWatch
  164. 3359Find Sorted Submatrices With Maximum Element at Most KLocked
  165. 3412Find Mirror Score of a StringWatch
  166. 3420Count Non-Decreasing Subarrays After K OperationsWatch
  167. 3430Maximum and Minimum Sums of at Most Size K SubarraysWatch
  168. 3523Make Array Non-decreasingWatch
  169. 3542Minimum Operations to Convert All Elements to ZeroWatch
  170. 3555Smallest Subarray to Sort in Every Sliding WindowLocked
  171. 3561Resulting String After Adjacent RemovalsWatch
  172. 3638Maximum Balanced ShipmentsWatch
  173. 3676Count Bowl SubarraysWatch
  174. 3703Remove K-Balanced SubstringsWatch
  175. 3746Minimum String Length After Balanced RemovalsWatch
  176. 3749Evaluate Valid ExpressionsLocked
  177. 3816Lexicographically Smallest String After Deleting Duplicate CharactersWatch
  178. 3834Merge Adjacent Equal ElementsWatch
  179. 3878Count Good SubarraysWatch
  180. 4045Count Robot GroupsWatch
  181. 4054Count Shadow Pairs IWatch
  182. 4055Count Shadow Pairs IIWatch