Stacks
29 problems to practice.
Next Greater Element To The Right
1. You are given a number n, representing the size of array a. 2. You are given n numbers, represen...
Next Greater Element I
1: You are given two integer arrays query and nums containing unique elements. 2: Here query is a s...
Next Greater Element Ii
Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), re...
Validate Stack Sequences
1: Given two sequences pushed and popped with distinct values. 2: You have to return true if and on...
Design A Stack With Increment Operation
Design a stack which supports the following operations. Implement the CustomStack class: 1...
Minimum Add To Make Parentheses Valid
1: Given a string S of '(' and ')' parentheses. 2: You need to find count of minimum number of pare...
Score Of Parentheses
Given a balanced parentheses string S, compute the score of the string based on the following rule:...
Reverse Substrings Between Each Pair Of Parentheses
1: You are given a string s that consists of lower case English letters and brackets. 2: Reverse t...
Minimum Remove To Make Valid Parentheses
1: Given a string s of '(' , ')' and lowercase English characters 2: Your task is to remove the min...
Online Stock Span
1: Complete the next function in class StockSpanner which collects daily price quotes for some stock...
Exclusive Time Of Functions
1: On a single-threaded CPU, we execute a program containing n functions. Each function has a unique...
132 Pattern
Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j]...
Remove K Digits
Given string num representing a non-negative integer num, and an integer k, print the smallest possi...
Asteroid Collision
1. You are given an array asteroids of integers representing asteroids in a row. 2. For each astero...
Remove Duplicate Letters
1. Given a string s, remove duplicate letters so that every letter appears once and only once. 2. Y...
Largest Area Histogram 2
1. You are given a number n, representing the size of array a. 2. You are given n numbers, represen...
Maximal Rectangle
1. Given a rows x cols binary matrix filled with 0's and 1's. 2. Find the largest rectangle contain...
Trapping Rain Water
1. Given n non-negative integers representing an elevation map where the width of each bar is 1. 2....
Basic Calculator
Given a string s representing an expression, implement a basic calculator to evaluate it.
Number Of Valid Subarrays
Given an array nums of integers, return the number of non-empty continuous subarrays that satisfy th...
Basic Calculator Ii
1. Given a string s which represents an expression, evaluate this expression and return its value....
Basic Calculator Iii
1. Implement a basic calculator to evaluate a simple expression string. 2. String will contain only...
Lexicographically Smallest Subsequence
1. Given an integer array nums and a positive integer k; 2. return the lexicographically smallest s...
Max-stack
Design a max stack data structure that supports the stack operations and supports finding the stack'...
Check If Word Is Valid After Insertion
1. You are given a string s determine if it is valid or not. 2. A valid string is a string that can...
Moving Average From Data Stream
Given a stream of integers and a window size, calculate the moving average of all integers in the sl...
Number Of Recent Calls
You have a RecentCounter class which counts the number of recent requests within a certain time fram...
Design Circular Deque
Design your implementation of the circular double-ended queue (deque). Your implementation should...
Remove Outermost Parentheses
1. You are given a valid parentheses string in form of A+B+C... where A, B and C are valid primitive...