Stack

Stack

Forty questions on stacks, for parsing, backtracking, and problems that need to undo the most recent operation first.

Backspace String Compare

easy
Given two strings s and t, return true if they are equal when both are typed into empty text editors.

Clear Digits

easy
You are given a string s.

Crawler Log Folder

easy
A file system keeps a log each time some user performs a change folder operation.

Final Prices With a Special Discount in a Shop

easy
You are given an integer array prices where prices[i] is the price of the ith item in a shop.

Make The String Great

easy
Given a string s of lower and upper case English letters.

Maximum Nesting Depth of the Parentheses

easy
Given a valid parentheses string s, return the nesting depth of s.

Minimum String Length After Removing Substrings

easy
You are given a string s consisting only of uppercase English letters.

Next Greater Element I

easy
The 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

easy
The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively.

Remove All Adjacent Duplicates In String

easy
You are given a string s consisting of lowercase English letters.

Remove Outermost Parentheses

easy
A 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

easy
Given 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

easy
Determine if a string of brackets is properly matched and nested.

132 Pattern

medium
Given 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

medium
We are given an array asteroids of integers representing asteroids in a row.

Basic Calculator II

medium
Given a string s which represents an expression, evaluate this expression and return its value.

Beautiful Towers I

medium
You are given an array heights of n integers representing the number of bricks in n consecutive towers.

Beautiful Towers II

medium
You are given a 0-indexed array maxHeights of n integers.

Build an Array With Stack Operations

medium
You are given an integer array target and an integer n.

Car Fleet

medium
There 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

medium
A parentheses string is a non-empty string consisting only of '(' and ')'.

Check If Word Is Valid After Substitutions

medium
Given a string s, determine if it is valid.

Clumsy Factorial

medium
The 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

medium
You 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

medium
There are n cars on an infinitely long road.

Count Submatrices With All Ones

medium
Given an m x n binary matrix mat, return the number of submatrices that have all ones.

Daily Temperatures

medium
Given 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

medium
Given an encoded string, return its decoded string.

Decoded String at Index

medium
You are given an encoded string s.

Evaluate Reverse Polish Notation

medium
You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation.

Exclusive Time of Functions

medium
On a single-threaded CPU, we execute a program containing n functions.

Find Mirror Score of a String

medium
You are given a string s.

Find the Most Competitive Subsequence

medium
Given 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

medium
You are given a string s.

Longest Absolute File Path

medium
Suppose we have a file system that stores both files and directories.

Longest Well-Performing Interval

medium
We are given hours, a list of the number of hours worked per day for a given employee.

Make Array Non-decreasing

medium
You are given an integer array nums.

Max Chunks To Make Sorted

medium
You 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

medium
A 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

medium
You are given a string s and two integers x and y.