Stack / Monotonic Stack Pattern

Track candidates with LIFO order or monotonic properties.

#Title
20Valid Parentheses
32Longest Valid Parentheses
71Simplify Path
84Largest Rectangle in Histogram
85Maximal Rectangle
101Symmetric Tree
150Evaluate Reverse Polish Notation
155Min Stack
188Best Time to Buy and Sell Stock IV
224Basic Calculator
227Basic Calculator II
232Implement Queue using Stacks
255Verify Preorder Sequence in Binary Search Tree
272Closest Binary Search Tree Value II
316Remove Duplicate Letters
331Verify Preorder Serialization of a Binary Tree
341Flatten Nested List Iterator
385Mini Parser
388Longest Absolute File Path
394Decode String
439Ternary Expression Parser
456132 Pattern
496Next Greater Element I
503Next Greater Element II
636Exclusive Time of Functions
654Maximum Binary Tree
682Baseball Game
726Number of Atoms
735Asteroid Collision
736Parse Lisp Expression
739Daily Temperatures
768Max Chunks To Make Sorted II
770Basic Calculator IV
772Basic Calculator III
853Car Fleet
856Score of Parentheses
872Leaf-Similar Trees
889Construct Binary Tree from Preorder and Postorder Traversal
895Maximum Frequency Stack
901Online Stock Span
907Sum of Subarray Minimums
921Minimum Add to Make Parentheses Valid
946Validate Stack Sequences
962Maximum Width Ramp
975Odd Even Jump
1003Check If Word Is Valid After Substitutions
1019Next Greater Node In Linked List
1021Remove Outermost Parentheses
1047Remove All Adjacent Duplicates In String
1063Number of Valid Subarrays
1081Smallest Subsequence of Distinct Characters
1130Minimum Cost Tree From Leaf Values
1190Reverse Substrings Between Each Pair of Parentheses
1209Remove All Adjacent Duplicates in String II
1214Two Sum BSTs
1249Minimum Remove to Make Valid Parentheses
1286Iterator for Combination
1305All Elements in Two Binary Search Trees
1340Jump Game V
1373Maximum Sum BST in Binary Tree
1377Frog Position After T Seconds
1379Find a Corresponding Node of a Binary Tree in a Clone of That Tree
1382Balance a Binary Search Tree
1430Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree
1441Build an Array With Stack Operations
1443Minimum Time to Collect All Apples in a Tree
1448Count Good Nodes in Binary Tree
1457Pseudo-Palindromic Paths in a Binary Tree
1466Reorder Routes to Make All Paths Lead to the City Zero
1469Find All The Lonely Nodes
1475Final Prices With a Special Discount in a Shop
1485Clone Binary Tree With Random Pointer
1490Clone N-ary Tree
1504Count Submatrices With All Ones
1516Move Sub-Tree of N-Ary Tree
1519Number of Nodes in the Sub-Tree With the Same Label
1522Diameter of N-Ary Tree
1530Number of Good Leaf Nodes Pairs
1541Minimum Insertions to Balance a Parentheses String
1597Build Binary Expression Tree From Infix Expression
1612Check If Two Expression Trees are Equivalent
1644Lowest Common Ancestor of a Binary Tree II
1673Find the Most Competitive Subsequence
1676Lowest Common Ancestor of a Binary Tree IV
1776Car Fleet II
1856Maximum Subarray Min-Product
1896Minimum Cost to Change the Final Value of Expression
1944Number of Visible People in a Queue
1950Maximum of Minimum Values in All Subarrays
2003Smallest Missing Genetic Value in Each Subtree
2030Smallest K-Length Subsequence With Occurrences of a Letter
2096Step-By-Step Directions From a Binary Tree Node to Another
2104Sum of Subarray Ranges
2197Replace Non-Coprime Numbers in Array
2281Sum of Total Strength of Wizards
2282Number of People That Can Be Seen in a Grid
2289Steps to Make Array Non-decreasing
2296Design a Text Editor
2297Jump Game VIII
2334Subarray With Elements Greater Than Varying Threshold
2345Finding the Number of Visible Mountains
2355Maximum Number of Books You Can Take
2378Choose Edges to Maximize Score in a Tree
2390Removing Stars From a String
2454Next Greater Element IV
2487Remove Nodes From Linked List
2696Minimum String Length After Removing Substrings
2735Collecting Chocolates
2736Maximum Sum Queries
2751Robot Collisions
2759Convert JSON String to Object
2764is Array a Preorder of Some ‌Binary Tree
2818Apply Operations to Maximize Score
2832Maximal Range That Each Element Is Maximum in It
2863Maximum Length of Semi-Decreasing Subarrays
2865Beautiful Towers I
2866Beautiful Towers II
2876Count Visited Nodes in a Directed Graph
2899Last Visited Integers
2907Maximum Profitable Triplets With Increasing Prices I
2921Maximum Profitable Triplets With Increasing Prices II
2926Maximum Balanced Subsequence Sum
2940Find Building Where Alice and Bob Can Meet
2945Find Maximum Non-decreasing Array Length
3113Find the Number of Subarrays Where Boundary Elements Are Maximum
3170Lexicographically Minimum String After Removing Stars
3174Clear Digits
3359Find Sorted Submatrices With Maximum Element at Most K
3412Find Mirror Score of a String
3542Minimum Operations to Convert All Elements to Zero
3555Smallest Subarray to Sort in Every Sliding Window
3561Resulting String After Adjacent Removals
3676Count Bowl Subarrays
3703Remove K-Balanced Substrings
3749Evaluate Valid Expressions
3814Maximum Capacity Within Budget
3834Merge Adjacent Equal Elements
3878Count Good Subarrays