Stack Problems
Master stack problems with AI-powered solutions. Get instant coding assistance during your technical interviews for all 120 problems in this category.
Total Problems: 120
Easy: 23
Medium: 65
Hard: 32
Showing 50 of 120 problems
Problems
Scroll within this area to browse all problems
#
Title
Difficulty
Stack LeetCode Problems List
- 144. Binary Tree Preorder Traversal - Easy - StackGiven the root of a binary tree, return the preorder traversal of its nodes' values.... Topics: Stack, Tree, Depth-First Search, Binary Tree
- 94. Binary Tree Inorder Traversal - Easy - StackGiven the root of a binary tree, return the inorder traversal of its nodes' values.... Topics: Stack, Tree, Depth-First Search, Binary Tree
- 145. Binary Tree Postorder Traversal - Easy - StackGiven the root of a binary tree, return the postorder traversal of its nodes' values.... Topics: Stack, Tree, Depth-First Search, Binary Tree
- 20. Valid Parentheses - Easy - StackGiven a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: ... Topics: String, Stack
- 42. Trapping Rain Water - Hard - StackGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.... Topics: Array, Two Pointers, Dynamic Programming, Stack, Monotonic Stack
- 234. Palindrome Linked List - Easy - StackGiven the head of a singly linked list, return true if it is a palindrome or false otherwise.... Topics: Linked List, Two Pointers, Stack, Recursion
- 224. Basic Calculator - Hard - StackGiven a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result of the evaluation. Note: You are ... Topics: Math, String, Stack, Recursion
- 155. Min Stack - Medium - StackDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: MinStack() initializes... Topics: Stack, Design
- 114. Flatten Binary Tree to Linked List - Medium - StackGiven the root of a binary tree, flatten the tree into a "linked list": The "linked list" should use the same TreeNode class where the right child poi... Topics: Linked List, Stack, Tree, Depth-First Search, Binary Tree
- 227. Basic Calculator II - Medium - StackGiven a string s which represents an expression, evaluate this expression and return its value. The integer division should truncate toward zero. You ... Topics: Math, String, Stack
- 496. Next Greater Element I - Easy - StackThe next greater element of some element x in an array is the first greater element that is to the right of x in the same array. You are given two dis... Topics: Array, Hash Table, Stack, Monotonic Stack
- 735. Asteroid Collision - Medium - StackWe are given an array asteroids of integers representing asteroids in a row. The indices of the asteriod in the array represent their relative positio... Topics: Array, Stack, Simulation
- 394. Decode String - Medium - StackGiven an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is be... Topics: String, Stack, Recursion
- 883. Car Fleet - Medium - StackThere are n cars at given miles away from the starting mile 0, traveling to reach the mile target. You are given two integer arrays position and speed... Topics: Array, Stack, Sorting, Monotonic Stack
- 71. Simplify Path - Medium - StackYou are given an absolute path for a Unix-style file system, which always begins with a slash '/'. Your task is to transform this absolute path into i... Topics: String, Stack
- 1570. Final Prices With a Special Discount in a Shop - Easy - StackYou are given an integer array prices where prices[i] is the price of the ith item in a shop. There is a special discount for items in the shop. If yo... Topics: Array, Stack, Monotonic Stack
- 32. Longest Valid Parentheses - Hard - StackGiven a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring.... Topics: String, Dynamic Programming, Stack
- 225. Implement Stack using Queues - Easy - StackImplement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (push, top,... Topics: Stack, Design, Queue
- 456. 132 Pattern - Medium - StackGiven an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < num... Topics: Array, Binary Search, Stack, Monotonic Stack, Ordered Set
- 341. Flatten Nested List Iterator - Medium - StackYou are given a nested list of integers nestedList. Each element is either an integer or a list whose elements may also be integers or other lists. Im... Topics: Stack, Tree, Depth-First Search, Design, Queue, Iterator
- 232. Implement Queue using Stacks - Easy - StackImplement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, pee... Topics: Stack, Design, Queue
- 143. Reorder List - Medium - StackYou are given the head of a singly linked-list. The list can be represented as: L0 → L1 → … → Ln - 1 → Ln Reorder the list to be on the following form... Topics: Linked List, Two Pointers, Stack, Recursion
- 503. Next Greater Element II - Medium - StackGiven a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in ... Topics: Array, Stack, Monotonic Stack
- 2021. Remove All Occurrences of a Substring - Medium - StackGiven two strings s and part, perform the following operation on s until all occurrences of the substring part are removed: Find the leftmost occurren... Topics: String, Stack, Simulation
- 937. Online Stock Span - Medium - StackDesign an algorithm that collects daily price quotes for some stock and returns the span of that stock's price for the current day. The span of the st... Topics: Stack, Design, Monotonic Stack, Data Stream
- 726. Number of Atoms - Hard - StackGiven a string formula representing a chemical formula, return the count of each atom. The atomic element always starts with an uppercase character, t... Topics: Hash Table, String, Stack, Sorting
- 150. Evaluate Reverse Polish Notation - Medium - StackYou are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation. Evaluate the expression. Return an int... Topics: Array, Math, Stack
- 1128. Remove All Adjacent Duplicates In String - Easy - StackYou are given a string s consisting of lowercase English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing... Topics: String, Stack
- 173. Binary Search Tree Iterator - Medium - StackImplement the BSTIterator class that represents an iterator over the in-order traversal of a binary search tree (BST): BSTIterator(TreeNode root) Init... Topics: Stack, Tree, Design, Binary Search Tree, Binary Tree, Iterator
- 316. Remove Duplicate Letters - Medium - StackGiven a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicogr... Topics: String, Stack, Greedy, Monotonic Stack
- 678. Valid Parenthesis String - Medium - StackGiven a string s containing only three types of characters: '(', ')' and '*', return true if s is valid. The following rules define a valid string: An... Topics: String, Dynamic Programming, Stack, Greedy
- 591. Tag Validator - Hard - StackGiven a string representing a code snippet, implement a tag validator to parse the code and return whether it is valid. A code snippet is valid if all... Topics: String, Stack
- 1197. Parsing A Boolean Expression - Hard - StackA boolean expression is an expression that evaluates to either true or false. It can be in one of the following shapes: 't' that evaluates to true. 'f... Topics: String, Stack, Recursion
- 2871. Double a Number Represented as a Linked List - Medium - StackYou are given the head of a non-empty linked list representing a non-negative integer without leading zeroes. Return the head of the linked list after... Topics: Linked List, Math, Stack
- 84. Largest Rectangle in Histogram - Hard - StackGiven an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle ... Topics: Array, Stack, Monotonic Stack
- 874. Backspace String Compare - Easy - StackGiven two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character. Note that after... Topics: Two Pointers, String, Stack, Simulation
- 581. Shortest Unsorted Continuous Subarray - Medium - StackGiven an integer array nums, you need to find one continuous subarray such that if you only sort this subarray in non-decreasing order, then the whole... Topics: Array, Two Pointers, Stack, Greedy, Sorting, Monotonic Stack
- 321. Create Maximum Number - Hard - StackYou are given two integer arrays nums1 and nums2 of lengths m and n respectively. nums1 and nums2 represent the digits of two numbers. You are also gi... Topics: Array, Two Pointers, Stack, Greedy, Monotonic Stack
- 682. Baseball Game - Easy - StackYou are keeping the scores for a baseball game with strange rules. At the beginning of the game, you start with an empty record. You are given a list ... Topics: Array, Stack, Simulation
- 1582. Design Browser History - Medium - StackYou have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward i... Topics: Array, Linked List, Stack, Design, Doubly-Linked List, Data Stream
- 1078. Remove Outermost Parentheses - Easy - StackA valid parentheses string is either empty "", "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatena... Topics: String, Stack
- 1320. Remove All Adjacent Duplicates in String II - Medium - StackYou are given a string s and an integer k, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them, causing t... Topics: String, Stack
- 1050. Construct Binary Search Tree from Preorder Traversal - Medium - StackGiven an array of integers preorder, which represents the preorder traversal of a BST (i.e., binary search tree), construct the tree and return its ro... Topics: Array, Stack, Tree, Binary Search Tree, Monotonic Stack, Binary Tree
- 739. Daily Temperatures - Medium - StackGiven an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have t... Topics: Array, Stack, Monotonic Stack
- 1188. Brace Expansion II - Hard - StackUnder the grammar given below, strings can represent a set of lowercase words. Let R(expr) denote the set of words the expression represents. The gram... Topics: String, Backtracking, Stack, Breadth-First Search
- 931. Maximum Frequency Stack - Hard - StackDesign a stack-like data structure to push elements to the stack and pop the most frequent element from the stack. Implement the FreqStack class: Freq... Topics: Hash Table, Stack, Design, Ordered Set
- 3114. Beautiful Towers I - Medium - StackYou are given an array heights of n integers representing the number of bricks in n consecutive towers. Your task is to remove some bricks to form a m... Topics: Array, Stack, Monotonic Stack
- 1371. Minimum Remove to Make Valid Parentheses - Medium - StackGiven a string s of '(' , ')' and lowercase English characters. Your task is to remove the minimum number of parentheses ( '(' or ')', in any position... Topics: String, Stack
- 781. Basic Calculator IV - Hard - StackGiven an expression such as expression = "e + 8 - a + 5" and an evaluation map such as {"e": 1} (given in terms of evalvars = ["e"] and evalints = [1]... Topics: Hash Table, Math, String, Stack, Recursion
- 957. Minimum Add to Make Parentheses Valid - Medium - StackA parentheses string is valid if and only if: It is the empty string, It can be written as AB (A concatenated with B), where A and B are valid strings... Topics: String, Stack, Greedy
- 3113. Beautiful Towers II - Medium - StackYou are given a 0-indexed array maxHeights of n integers. You are tasked with building n towers in the coordinate line. The ith tower is built at coor... Topics: Array, Stack, Monotonic Stack
- 1902. Car Fleet II - Hard - StackThere are n cars traveling at different speeds in the same direction along a one-lane road. You are given an array cars of length n, where cars[i] = [... Topics: Array, Math, Stack, Heap (Priority Queue), Monotonic Stack
- 2227. Sum of Subarray Ranges - Medium - StackYou are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the subarray. Retur... Topics: Array, Stack, Monotonic Stack
- 2221. Check if a Parentheses String Can Be Valid - Medium - StackA parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true: It is (). It can be... Topics: String, Stack, Greedy
- 1305. Number of Visible People in a Queue - Hard - StackThere are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers ... Topics: Array, Stack, Monotonic Stack
- 1737. Maximum Nesting Depth of the Parentheses - Easy - StackGiven a valid parentheses string s, return the nesting depth of s. The nesting depth is the maximum number of nested parentheses.... Topics: String, Stack
- 943. Sum of Subarray Minimums - Medium - StackGiven an array of integers arr, find the sum of min(b), where b ranges over every (contiguous) subarray of arr. Since the answer may be large, return ... Topics: Array, Dynamic Programming, Stack, Monotonic Stack
- 402. Remove K Digits - Medium - StackGiven string num representing a non-negative integer num, and an integer k, return the smallest possible integer after removing k digits from num.... Topics: String, Stack, Greedy, Monotonic Stack
- 2317. Count Collisions on a Road - Medium - StackThere are n cars on an infinitely long road. The cars are numbered from 0 to n - 1 from left to right and each car is present at a unique point. You a... Topics: String, Stack, Simulation
- 3181. Find Building Where Alice and Bob Can Meet - Hard - StackYou are given a 0-indexed array heights of positive integers, where heights[i] represents the height of the ith building. If a person is in building i... Topics: Array, Binary Search, Stack, Binary Indexed Tree, Segment Tree, Heap (Priority Queue), Monotonic Stack
- 776. N-ary Tree Postorder Traversal - Easy - StackGiven the root of an n-ary tree, return the postorder traversal of its nodes' values. Nary-Tree input serialization is represented in their level orde... Topics: Stack, Tree, Depth-First Search
- 775. N-ary Tree Preorder Traversal - Easy - StackGiven the root of an n-ary tree, return the preorder traversal of its nodes' values. Nary-Tree input serialization is represented in their level order... Topics: Stack, Tree, Depth-First Search
- 2736. Minimum Additions to Make Valid String - Medium - StackGiven a string word to which you can insert letters "a", "b" or "c" anywhere and any number of times, return the minimum number of letters that must b... Topics: String, Dynamic Programming, Stack, Greedy
- 1628. Count Submatrices With All Ones - Medium - StackGiven an m x n binary matrix mat, return the number of submatrices that have all ones.... Topics: Array, Dynamic Programming, Stack, Matrix, Monotonic Stack
- 1720. Crawler Log Folder - Easy - StackThe Leetcode file system keeps a log each time some user performs a change folder operation. The operations are described below: "../" : Move to the p... Topics: Array, String, Stack
- 488. Zuma Game - Hard - StackYou are playing a variation of the game Zuma. In this variation of Zuma, there is a single row of colored balls on a board, where each ball can be col... Topics: String, Dynamic Programming, Stack, Breadth-First Search, Memoization
- 1648. Minimum Insertions to Balance a Parentheses String - Medium - StackGiven a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if: Any left parenthesis '(' must have a cor... Topics: String, Stack, Greedy
- 2368. Sum of Total Strength of Wizards - Hard - StackAs the ruler of a kingdom, you have an army of wizards at your command. You are given a 0-indexed integer array strength, where strength[i] denotes th... Topics: Array, Stack, Monotonic Stack, Prefix Sum
- 2147. The Score of Students Solving Math Expression - Hard - StackYou are given a string s that contains digits 0-9, addition symbols '+', and multiplication symbols '*' only, representing a valid math expression of ... Topics: Array, Hash Table, Math, String, Dynamic Programming, Stack, Memoization
- 1985. Maximum Subarray Min-Product - Medium - StackThe min-product of an array is equal to the minimum value in the array multiplied by the array's sum. For example, the array [3,2,5] (minimum value is... Topics: Array, Stack, Monotonic Stack, Prefix Sum
- 2123. The Number of Weak Characters in the Game - Medium - StackYou are playing a game that contains multiple characters, and each of the characters has two main properties: attack and defense. You are given a 2D i... Topics: Array, Stack, Greedy, Sorting, Monotonic Stack
- 916. Decoded String at Index - Medium - StackYou are given an encoded string s. To decode the string to a tape, the encoded string is read one character at a time and the following steps are take... Topics: String, Stack
- 1802. Number of Students Unable to Eat Lunch - Easy - StackThe school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue.... Topics: Array, Stack, Queue, Simulation
- 2389. Design a Text Editor - Hard - StackDesign a text editor with a cursor that can do the following: Add text to where the cursor is. Delete text from where the cursor is (simulating the ba... Topics: Linked List, String, Stack, Design, Simulation, Doubly-Linked List
- 983. Validate Stack Sequences - Medium - StackGiven two integer arrays pushed and popped each with distinct values, return true if this could have been the result of a sequence of push and pop ope... Topics: Array, Stack, Simulation
- 2128. Reverse Prefix of Word - Easy - StackGiven a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ... Topics: Two Pointers, String, Stack
- 1552. Build an Array With Stack Operations - Medium - StackYou are given an integer array target and an integer n. You have an empty stack with the two following operations: "Push": pushes an integer to the to... Topics: Array, Stack, Simulation
- 445. Add Two Numbers II - Medium - StackYou are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contai... Topics: Linked List, Math, Stack
- 2470. Removing Stars From a String - Medium - StackYou are given a string s, which contains stars *. In one operation, you can: Choose a star in s. Remove the closest non-star character to its left, as... Topics: String, Stack, Simulation
- 85. Maximal Rectangle - Hard - StackGiven a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.... Topics: Array, Dynamic Programming, Stack, Matrix, Monotonic Stack
- 2573. Remove Nodes From Linked List - Medium - StackYou are given the head of a linked list. Remove every node which has a node with a greater value anywhere to the right side of it. Return the head of ... Topics: Linked List, Stack, Recursion, Monotonic Stack
- 1633. Minimum Number of Increments on Subarrays to Form a Target Array - Hard - StackYou are given an integer array target. You have an integer array initial of the same size as target with all elements initially zeros. In one operatio... Topics: Array, Dynamic Programming, Stack, Greedy, Monotonic Stack
- 1497. Design a Stack With Increment Operation - Medium - StackDesign a stack that supports increment operations on its elements. Implement the CustomStack class: CustomStack(int maxSize) Initializes the object wi... Topics: Array, Stack, Design
- 654. Maximum Binary Tree - Medium - StackYou are given an integer array nums with no duplicates. A maximum binary tree can be built recursively from nums using the following algorithm: Create... Topics: Array, Divide and Conquer, Stack, Tree, Monotonic Stack, Binary Tree
- 2800. Minimum String Length After Removing Substrings - Easy - StackYou are given a string s consisting only of uppercase English letters. You can apply some operations to this string where, in one operation, you can r... Topics: String, Stack, Simulation
- 3382. Find the Number of Subarrays Where Boundary Elements Are Maximum - Hard - StackYou are given an array of positive integers nums. Return the number of subarrays of nums, where the first and the last elements of the subarray are eq... Topics: Array, Binary Search, Stack, Monotonic Stack
- 1017. Odd Even Jump - Hard - StackYou are given an integer array arr. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called ... Topics: Array, Dynamic Programming, Stack, Sorting, Monotonic Stack, Ordered Set
- 2419. Subarray With Elements Greater Than Varying Threshold - Hard - StackYou are given an integer array nums and an integer threshold. Find any subarray of nums of length k such that every element in the subarray is greater... Topics: Array, Stack, Union Find, Monotonic Stack
- 388. Longest Absolute File Path - Medium - StackSuppose we have a file system that stores both files and directories. An example of one system is represented in the following picture: Here, we have ... Topics: String, Stack, Depth-First Search
- 3634. Find Mirror Score of a String - Medium - StackYou are given a string s. We define the mirror of a letter in the English alphabet as its corresponding letter when the alphabet is reversed. For exam... Topics: Hash Table, String, Stack, Simulation
- 1918. Maximum Score of a Good Subarray - Hard - StackYou are given an array of integers nums (0-indexed) and an integer k. The score of a subarray (i, j) is defined as min(nums[i], nums[i+1], ..., nums[j... Topics: Array, Two Pointers, Binary Search, Stack, Monotonic Stack
- 331. Verify Preorder Serialization of a Binary Tree - Medium - StackOne way to serialize a binary tree is to use preorder traversal. When we encounter a non-null node, we record the node's value. If it is a null node, ... Topics: String, Stack, Tree, Binary Tree
- 3447. Clear Digits - Easy - StackYou are given a string s. Your task is to remove all digits by doing this operation repeatedly: Delete the first digit and the closest non-digit chara... Topics: String, Stack, Simulation
- 2520. Using a Robot to Print the Lexicographically Smallest String - Medium - StackYou are given a string s and a robot that currently holds an empty string t. Apply one of the following operations until s and t are both empty: Remov... Topics: Hash Table, String, Stack, Greedy
- 636. Exclusive Time of Functions - Medium - StackOn a single-threaded CPU, we execute a program containing n functions. Each function has a unique ID between 0 and n-1. Function calls are stored in a... Topics: Array, Stack
- 1270. Dinner Plate Stacks - Hard - StackYou have an infinite number of stacks arranged in a row and numbered (left to right) from 0, each of the stacks has the same maximum capacity. Impleme... Topics: Hash Table, Stack, Design, Heap (Priority Queue)
- 1072. Next Greater Node In Linked List - Medium - StackYou are given the head of a linked list with n nodes. For each node in the list, find the value of the next greater node. That is, for each node, find... Topics: Array, Linked List, Stack, Monotonic Stack
- 3725. Maximum and Minimum Sums of at Most Size K Subarrays - Hard - StackYou are given an integer array nums and a positive integer k. Return the sum of the maximum and minimum elements of all subarrays with at most k eleme... Topics: Array, Math, Stack, Monotonic Stack
- 2846. Robot Collisions - Hard - StackThere are n 1-indexed robots, each having a position on a line, health, and movement direction. You are given 0-indexed integer arrays positions, heal... Topics: Array, Stack, Sorting, Simulation
- 3860. Resulting String After Adjacent Removals - Medium - StackYou are given a string s consisting of lowercase English letters. You must repeatedly perform the following operation while the string s has at least ... Topics: String, Stack, Simulation
- 779. Max Chunks To Make Sorted II - Hard - StackYou are given an integer array arr. We split arr into some number of chunks (i.e., partitions), and individually sort each chunk. After concatenating ... Topics: Array, Stack, Greedy, Sorting, Monotonic Stack
- 3445. Lexicographically Minimum String After Removing Stars - Medium - StackYou are given a string s. It may contain any number of '*' characters. Your task is to remove all '*' characters. While there is a '*', do the followi... Topics: Hash Table, String, Stack, Greedy, Heap (Priority Queue)
- 780. Max Chunks To Make Sorted - Medium - StackYou are given an integer array arr of length n that represents a permutation of the integers in the range [0, n - 1]. We split arr into some number of... Topics: Array, Stack, Greedy, Sorting, Monotonic Stack
- 1355. Minimum Deletions to Make Array Beautiful - Medium - StackYou are given a 0-indexed integer array nums. The array nums is beautiful if: nums.length is even. nums[i] != nums[i + 1] for all i % 2 == 0. Note tha... Topics: Array, Stack, Greedy
- 2095. Minimum Number of Swaps to Make the String Balanced - Medium - StackYou are given a 0-indexed string s of even length n. The string consists of exactly n / 2 opening brackets '[' and n / 2 closing brackets ']'. A strin... Topics: Two Pointers, String, Stack, Greedy
- 1666. Make The String Great - Easy - StackGiven a string s of lower and upper case English letters. A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where... Topics: String, Stack
- 3954. Maximum Balanced Shipments - Medium - StackYou are given an integer array weight of length n, representing the weights of n parcels arranged in a straight line. A shipment is defined as a conti... Topics: Array, Dynamic Programming, Stack, Greedy, Monotonic Stack
- 2008. Minimum Cost to Change the Final Value of Expression - Hard - StackYou are given a valid boolean expression as a string expression consisting of the characters '1','0','&' (bitwise AND operator),'|' (bitwise OR operat... Topics: Math, String, Dynamic Programming, Stack
- 933. Increasing Order Search Tree - Easy - StackGiven the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every no... Topics: Stack, Tree, Depth-First Search, Binary Search Tree, Binary Tree
- 886. Score of Parentheses - Medium - StackGiven a balanced parentheses string s, return the score of the string. The score of a balanced parentheses string is based on the following rule: "()"... Topics: String, Stack
- 1045. Check If Word Is Valid After Substitutions - Medium - StackGiven a string s, determine if it is valid. A string s is valid if, starting with an empty string t = "", you can transform t into s after performing ... Topics: String, Stack
- 1002. Maximum Width Ramp - Medium - StackA ramp in an integer array nums is a pair (i, j) for which i < j and nums[i] <= nums[j]. The width of such a ramp is j - i. Given an integer array num... Topics: Array, Two Pointers, Stack, Monotonic Stack
- 1048. Clumsy Factorial - Medium - StackThe factorial of a positive integer n is the product of all positive integers less than or equal to n. For example, factorial(10) = 10 * 9 * 8 * 7 * 6... Topics: Math, Stack, Simulation
- 1818. Maximum Score From Removing Substrings - Medium - StackYou are given a string s and two integers x and y. You can perform two types of operations any number of times. Remove substring "ab" and gain x point... Topics: String, Stack, Greedy
- 1228. Minimum Cost Tree From Leaf Values - Medium - StackGiven an array arr of positive integers, consider all binary trees such that: Each node has either 0 or 2 children; The values of arr correspond to th... Topics: Array, Dynamic Programming, Stack, Greedy, Monotonic Stack
- 2549. Next Greater Element IV - Hard - StackYou are given a 0-indexed array of non-negative integers nums. For each integer in nums, you must find its respective second greater integer. The seco... Topics: Array, Binary Search, Stack, Sorting, Heap (Priority Queue), Monotonic Stack
- 1159. Smallest Subsequence of Distinct Characters - Medium - StackGiven a string s, return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once.... Topics: String, Stack, Greedy, Monotonic Stack
- 2236. Maximum Twin Sum of a Linked List - Medium - StackIn a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n /... Topics: Linked List, Two Pointers, Stack
- 973. Stamping The Sequence - Hard - StackYou are given two strings stamp and target. Initially, there is a string s of length target.length with all s[i] == '?'. In one turn, you can place st... Topics: String, Stack, Greedy, Queue
- 2157. Smallest K-Length Subsequence With Occurrences of a Letter - Hard - StackYou are given a string s, an integer k, a letter letter, and an integer repetition. Return the lexicographically smallest subsequence of s of length k... Topics: String, Stack, Greedy, Monotonic Stack
Related LeetCode Topics
- Array LeetCode Problems
- Backtracking LeetCode Problems
- Biconnected Component LeetCode Problems
- Binary Indexed Tree LeetCode Problems
- Binary Search LeetCode Problems
- Binary Search Tree LeetCode Problems
- Binary Tree LeetCode Problems
- Bit Manipulation LeetCode Problems
- Bitmask LeetCode Problems
- Brainteaser LeetCode Problems
- Breadth-First Search LeetCode Problems
- Bucket Sort LeetCode Problems
- Combinatorics LeetCode Problems
- Concurrency LeetCode Problems
- Counting LeetCode Problems
- Counting Sort LeetCode Problems
- Data Stream LeetCode Problems
- Database LeetCode Problems
- Depth-First Search LeetCode Problems
- Design LeetCode Problems