Stacks and Queues Important Questions
Important points
- Balanced parantheses
- Next smaller/greater element to the left/right
- Sliding window maximum
- queue using two stacks and stack using 2 queues
- Stack = LIFO, Queue = FIFO
Easy/Medium (MUST DO)
- https://practice.geeksforgeeks.org/problems/queue-using-two-stacks/1 (IMPORTANT asked a lot in MCQs (for ex. Amazon))
- https://practice.geeksforgeeks.org/problems/stack-using-two-queues/1
- https://practice.geeksforgeeks.org/problems/parenthesis-checker/0 (Standard question for stacks)
- https://practice.geeksforgeeks.org/problems/get-minimum-element-from-stack/1 (IMPORTANT asked a number of times)
- https://www.interviewbit.com/problems/rain-water-trapped/ (IMPORTANT)
- https://leetcode.com/problems/simplify-path/
- https://leetcode.com/problems/moving-average-from-data-stream/
- https://leetcode.com/problems/design-circular-queue/ (IMPORTANT handle edge cases properply)
Hard
- https://www.interviewbit.com/problems/sliding-window-maximum/ (IMPORTANT)
- https://www.interviewbit.com/problems/largest-rectangle-in-histogram/
- https://www.interviewbit.com/problems/nearest-smaller-element/ (MOST IMPORTANT FOR STACKS)
- https://leetcode.com/problems/next-greater-node-in-linked-list/
- https://leetcode.com/problems/daily-temperatures/
- https://leetcode.com/problems/decode-string/ (IMPORTANT will require a bit of thinking)
- https://leetcode.com/problems/evaluate-reverse-polish-notation/