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
- 20Valid ParenthesesWatch
- 32Longest Valid ParenthesesWatch
- 42Trapping Rain WaterWatch
- 71Simplify PathWatch
- 84Largest Rectangle in HistogramWatch
- 85Maximal RectangleWatch
- 94Binary Tree Inorder TraversalWatch
- 114Flatten Binary Tree to Linked ListWatch
- 143Reorder ListWatch
- 144Binary Tree Preorder TraversalWatch
- 145Binary Tree Postorder TraversalWatch
- 150Evaluate Reverse Polish NotationWatch
- 155Min StackWatch
- 173Binary Search Tree IteratorWatch
- 224Basic CalculatorWatch
- 225Implement Stack using QueuesWatch
- 227Basic Calculator IIWatch
- 232Implement Queue using StacksWatch
- 234Palindrome Linked ListWatch
- 255Verify Preorder Sequence in Binary Search TreeLocked
- 272Closest Binary Search Tree Value IILocked
- 316Remove Duplicate LettersWatch
- 321Create Maximum NumberWatch
- 331Verify Preorder Serialization of a Binary TreeWatch
- 341Flatten Nested List IteratorWatch
- 364Nested List Weight Sum IILocked
- 385Mini ParserWatch
- 388Longest Absolute File PathWatch
- 394Decode StringWatch
- 402Remove K DigitsWatch
- 426Convert Binary Search Tree to Sorted Doubly Linked ListLocked
- 439Ternary Expression ParserLocked
- 445Add Two Numbers IIWatch
- 456132 PatternWatch
- 484Find PermutationLocked
- 488Zuma GameWatch
- 496Next Greater Element IWatch
- 503Next Greater Element IIWatch
- 536Construct Binary Tree from StringLocked
- 581Shortest Unsorted Continuous SubarrayWatch
- 589N-ary Tree Preorder TraversalWatch
- 590N-ary Tree Postorder TraversalWatch
- 591Tag ValidatorWatch
- 636Exclusive Time of FunctionsWatch
- 654Maximum Binary TreeWatch
- 678Valid Parenthesis StringWatch
- 682Baseball GameWatch
- 716Max StackLocked
- 726Number of AtomsWatch
- 735Asteroid CollisionWatch
- 736Parse Lisp ExpressionWatch
- 739Daily TemperaturesWatch
- 768Max Chunks To Make Sorted IIWatch
- 769Max Chunks To Make SortedWatch
- 770Basic Calculator IVWatch
- 772Basic Calculator IIILocked
- 844Backspace String CompareWatch
- 853Car FleetWatch
- 856Score of ParenthesesWatch
- 880Decoded String at IndexWatch
- 895Maximum Frequency StackWatch
- 897Increasing Order Search TreeWatch
- 901Online Stock SpanWatch
- 907Sum of Subarray MinimumsWatch
- 921Minimum Add to Make Parentheses ValidWatch
- 936Stamping The SequenceWatch
- 946Validate Stack SequencesWatch
- 962Maximum Width RampWatch
- 975Odd Even JumpWatch
- 1003Check If Word Is Valid After SubstitutionsWatch
- 1006Clumsy FactorialWatch
- 1008Construct Binary Search Tree from Preorder TraversalWatch
- 1019Next Greater Node In Linked ListWatch
- 1021Remove Outermost ParenthesesWatch
- 1047Remove All Adjacent Duplicates In StringWatch
- 1063Number of Valid SubarraysLocked
- 1081Smallest Subsequence of Distinct CharactersWatch
- 1087Brace ExpansionLocked
- 1096Brace Expansion IIWatch
- 1106Parsing A Boolean ExpressionWatch
- 1111Maximum Nesting Depth of Two Valid Parentheses StringsWatch
- 1124Longest Well-Performing IntervalWatch
- 1130Minimum Cost Tree From Leaf ValuesWatch
- 1172Dinner Plate StacksWatch
- 1190Reverse Substrings Between Each Pair of ParenthesesWatch
- 1209Remove All Adjacent Duplicates in String IIWatch
- 1214Two Sum BSTsLocked
- 1249Minimum Remove to Make Valid ParenthesesWatch
- 1265Print Immutable Linked List in ReverseLocked
- 1381Design a Stack With Increment OperationWatch
- 1441Build an Array With Stack OperationsWatch
- 1472Design Browser HistoryWatch
- 1475Final Prices With a Special Discount in a ShopWatch
- 1504Count Submatrices With All OnesWatch
- 1526Minimum Number of Increments on Subarrays to Form a Target ArrayWatch
- 1541Minimum Insertions to Balance a Parentheses StringWatch
- 1544Make The String GreatWatch
- 1574Shortest Subarray to be Removed to Make Array SortedWatch
- 1586Binary Search Tree Iterator IILocked
- 1597Build Binary Expression Tree From Infix ExpressionLocked
- 1598Crawler Log FolderWatch
- 1614Maximum Nesting Depth of the ParenthesesWatch
- 1628Design an Expression Tree With Evaluate FunctionLocked
- 1653Minimum Deletions to Make String BalancedWatch
- 1673Find the Most Competitive SubsequenceWatch
- 1700Number of Students Unable to Eat LunchWatch
- 1717Maximum Score From Removing SubstringsWatch
- 1762Buildings With an Ocean ViewLocked
- 1776Car Fleet IIWatch
- 1793Maximum Score of a Good SubarrayWatch
- 1856Maximum Subarray Min-ProductWatch
- 1896Minimum Cost to Change the Final Value of ExpressionWatch
- 1910Remove All Occurrences of a SubstringWatch
- 1944Number of Visible People in a QueueWatch
- 1950Maximum of Minimum Values in All SubarraysLocked
- 1963Minimum Number of Swaps to Make the String BalancedWatch
- 1966Binary Searchable Numbers in an Unsorted ArrayLocked
- 1996The Number of Weak Characters in the GameWatch
- 2000Reverse Prefix of WordWatch
- 2019The Score of Students Solving Math ExpressionWatch
- 2030Smallest K-Length Subsequence With Occurrences of a LetterWatch
- 2104Sum of Subarray RangesWatch
- 2116Check if a Parentheses String Can Be ValidWatch
- 2130Maximum Twin Sum of a Linked ListWatch
- 2197Replace Non-Coprime Numbers in ArrayWatch
- 2211Count Collisions on a RoadWatch
- 2216Minimum Deletions to Make Array BeautifulWatch
- 2281Sum of Total Strength of WizardsWatch
- 2282Number of People That Can Be Seen in a GridLocked
- 2289Steps to Make Array Non-decreasingWatch
- 2296Design a Text EditorWatch
- 2297Jump Game VIIILocked
- 2334Subarray With Elements Greater Than Varying ThresholdWatch
- 2345Finding the Number of Visible MountainsLocked
- 2355Maximum Number of Books You Can TakeLocked
- 2375Construct Smallest Number From DI StringWatch
- 2390Removing Stars From a StringWatch
- 2434Using a Robot to Print the Lexicographically Smallest StringWatch
- 2454Next Greater Element IVWatch
- 2487Remove Nodes From Linked ListWatch
- 2524Maximum Frequency Score of a SubarrayLocked
- 2589Minimum Time to Complete All TasksWatch
- 2617Minimum Number of Visited Cells in a GridWatch
- 2645Minimum Additions to Make Valid StringWatch
- 2696Minimum String Length After Removing SubstringsWatch
- 2736Maximum Sum QueriesWatch
- 2751Robot CollisionsWatch
- 2764Is Array a Preorder of Some Binary TreeLocked
- 2813Maximum Elegance of a K-Length SubsequenceWatch
- 2816Double a Number Represented as a Linked ListWatch
- 2818Apply Operations to Maximize ScoreWatch
- 2832Maximal Range That Each Element Is Maximum in ItLocked
- 2863Maximum Length of Semi-Decreasing SubarraysLocked
- 2865Beautiful Towers IWatch
- 2866Beautiful Towers IIWatch
- 2940Find Building Where Alice and Bob Can MeetWatch
- 2945Find Maximum Non-decreasing Array LengthWatch
- 3113Find the Number of Subarrays Where Boundary Elements Are MaximumWatch
- 3170Lexicographically Minimum String After Removing StarsWatch
- 3174Clear DigitsWatch
- 3205Maximum Array Hopping Score ILocked
- 3221Maximum Array Hopping Score IILocked
- 3229Minimum Operations to Make Array Equal to TargetWatch
- 3359Find Sorted Submatrices With Maximum Element at Most KLocked
- 3412Find Mirror Score of a StringWatch
- 3420Count Non-Decreasing Subarrays After K OperationsWatch
- 3430Maximum and Minimum Sums of at Most Size K SubarraysWatch
- 3523Make Array Non-decreasingWatch
- 3542Minimum Operations to Convert All Elements to ZeroWatch
- 3555Smallest Subarray to Sort in Every Sliding WindowLocked
- 3561Resulting String After Adjacent RemovalsWatch
- 3638Maximum Balanced ShipmentsWatch
- 3676Count Bowl SubarraysWatch
- 3703Remove K-Balanced SubstringsWatch
- 3746Minimum String Length After Balanced RemovalsWatch
- 3749Evaluate Valid ExpressionsLocked
- 3816Lexicographically Smallest String After Deleting Duplicate CharactersWatch
- 3834Merge Adjacent Equal ElementsWatch
- 3878Count Good SubarraysWatch
- 4045Count Robot GroupsWatch
- 4054Count Shadow Pairs IWatch
- 4055Count Shadow Pairs IIWatch