Stack
Stack
Forty questions on stacks, for parsing, backtracking, and problems that need to undo the most recent operation first.
Backspace String Compare
easyGiven two strings s and t, return true if they are equal when both are typed into empty text editors.
Clear Digits
easyYou are given a string s.
Crawler Log Folder
easyA file system keeps a log each time some user performs a change folder operation.
Final Prices With a Special Discount in a Shop
easyYou are given an integer array prices where prices[i] is the price of the ith item in a shop.
Make The String Great
easyGiven a string s of lower and upper case English letters.
Maximum Nesting Depth of the Parentheses
easyGiven a valid parentheses string s, return the nesting depth of s.
Minimum String Length After Removing Substrings
easyYou are given a string s consisting only of uppercase English letters.
Next Greater Element I
easyThe 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.
Number of Students Unable to Eat Lunch
easyThe school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively.
Remove All Adjacent Duplicates In String
easyYou are given a string s consisting of lowercase English letters.
Remove Outermost Parentheses
easyA valid parentheses string is either empty "", "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation.
Reverse Prefix of Word
easyGiven 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 ch (inclusive).
Valid Parentheses
easyDetermine if a string of brackets is properly matched and nested.
132 Pattern
mediumGiven 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] < nums[k] < nums[j].
Asteroid Collision
mediumWe are given an array asteroids of integers representing asteroids in a row.
Basic Calculator II
mediumGiven a string s which represents an expression, evaluate this expression and return its value.
Beautiful Towers I
mediumYou are given an array heights of n integers representing the number of bricks in n consecutive towers.
Beautiful Towers II
mediumYou are given a 0-indexed array maxHeights of n integers.
Build an Array With Stack Operations
mediumYou are given an integer array target and an integer n.
Car Fleet
mediumThere are n cars at given miles away from the starting mile 0, traveling to reach the mile target.
Check if a Parentheses String Can Be Valid
mediumA parentheses string is a non-empty string consisting only of '(' and ')'.
Check If Word Is Valid After Substitutions
mediumGiven a string s, determine if it is valid.
Clumsy Factorial
mediumThe factorial of a positive integer n is the product of all positive integers less than or equal to n.
Construct Smallest Number From DI String
mediumYou are given a 0-indexed string pattern of length n consisting of the characters 'I' meaning increasing and 'D' meaning decreasing.
Count Collisions on a Road
mediumThere are n cars on an infinitely long road.
Count Submatrices With All Ones
mediumGiven an m x n binary matrix mat, return the number of submatrices that have all ones.
Daily Temperatures
mediumGiven an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to...
Decode String
mediumGiven an encoded string, return its decoded string.
Decoded String at Index
mediumYou are given an encoded string s.
Evaluate Reverse Polish Notation
mediumYou are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation.
Exclusive Time of Functions
mediumOn a single-threaded CPU, we execute a program containing n functions.
Find Mirror Score of a String
mediumYou are given a string s.
Find the Most Competitive Subsequence
mediumGiven an integer array nums and a positive integer k, return the most competitive subsequence of nums of size k.
Lexicographically Minimum String After Removing Stars
mediumYou are given a string s.
Longest Absolute File Path
mediumSuppose we have a file system that stores both files and directories.
Longest Well-Performing Interval
mediumWe are given hours, a list of the number of hours worked per day for a given employee.
Make Array Non-decreasing
mediumYou are given an integer array nums.
Max Chunks To Make Sorted
mediumYou are given an integer array arr of length n that represents a permutation of the integers in the range [0, n - 1].
Maximum Nesting Depth of Two Valid Parentheses Strings
mediumA string is a valid parentheses string (denoted VPS) if and only if it consists of "(" and ")" characters only, and: We can similarly define the nesting depth depth(S) of any VPS...
Maximum Score From Removing Substrings
mediumYou are given a string s and two integers x and y.