Sliding Window Maximum LeetCode Solution

Problem Statement Sliding Window Maximum LeetCode Solution Says that – You are given an array of integers nums, and there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time …

Read more

Max stack

Problem Statement The problem “Max stack” states to design a special stack which can perform these operations : push(x): push one element into the stack. top(): returns the element that is at the top of the stack. pop(): remove the element from the stack which is at the top. peekmax(): …

Read more

Find Index of Closing Bracket for a Given Opening Bracket in an Expression

Problem Statement Given a string s of length/size n and an integer value representing the index of an opening square bracket. Find index of closing bracket for a given opening bracket in an expression. Example s = “[ABC[23]][89]” index = 0 8 s = “[C-[D]]” index = 3 5 s …

Read more

Design a stack that supports getMin() in O(1) time and O(1) extra space

Design a stack that supports getMin() in O(1) time and O(1) extra space. Thus the special stack data structure must support all the operations of the stack like – void push() int pop() bool isFull() bool isEmpty() in constant time. Add an additional operation getMin() to return the minimum value …

Read more

Translate »