Stacks

29 problems to practice.

29 Total
5 Easy
18 Medium
6 Hard

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...

medium

Next Greater Element I

1: You are given two integer arrays query and nums containing unique elements. 2: Here query is a s...

easy

Next Greater Element Ii

Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), re...

easy

Validate Stack Sequences

1: Given two sequences pushed and popped with distinct values. 2: You have to return true if and on...

medium

Design A Stack With Increment Operation

Design a stack which supports the following operations. Implement the CustomStack class: 1...

medium

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...

medium

Score Of Parentheses

Given a balanced parentheses string S, compute the score of the string based on the following rule:...

medium

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...

medium

Minimum Remove To Make Valid Parentheses

1: Given a string s of '(' , ')' and lowercase English characters 2: Your task is to remove the min...

medium

Online Stock Span

1: Complete the next function in class StockSpanner which collects daily price quotes for some stock...

medium

Exclusive Time Of Functions

1: On a single-threaded CPU, we execute a program containing n functions. Each function has a unique...

medium

132 Pattern

Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j]...

medium

Remove K Digits

Given string num representing a non-negative integer num, and an integer k, print the smallest possi...

medium

Asteroid Collision

1. You are given an array asteroids of integers representing asteroids in a row. 2. For each astero...

medium

Remove Duplicate Letters

1. Given a string s, remove duplicate letters so that every letter appears once and only once. 2. Y...

medium

Largest Area Histogram 2

1. You are given a number n, representing the size of array a. 2. You are given n numbers, represen...

hard

Maximal Rectangle

1. Given a rows x cols binary matrix filled with 0's and 1's. 2. Find the largest rectangle contain...

hard

Trapping Rain Water

1. Given n non-negative integers representing an elevation map where the width of each bar is 1. 2....

hard

Basic Calculator

Given a string s representing an expression, implement a basic calculator to evaluate it.

hard

Number Of Valid Subarrays

Given an array nums of integers, return the number of non-empty continuous subarrays that satisfy th...

hard

Basic Calculator Ii

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

medium

Basic Calculator Iii

1. Implement a basic calculator to evaluate a simple expression string. 2. String will contain only...

hard

Lexicographically Smallest Subsequence

1. Given an integer array nums and a positive integer k; 2. return the lexicographically smallest s...

medium

Max-stack

Design a max stack data structure that supports the stack operations and supports finding the stack'...

medium

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...

medium

Moving Average From Data Stream

Given a stream of integers and a window size, calculate the moving average of all integers in the sl...

easy

Number Of Recent Calls

You have a RecentCounter class which counts the number of recent requests within a certain time fram...

easy

Design Circular Deque

Design your implementation of the circular double-ended queue (deque). Your implementation should...

medium

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...

easy