šŸ“š Stacks & Queues Notes

āœ… Stack

āœ… Monotonic Stack

→ Next Greater / Smaller

→ Previous Greater / Smaller

→ Array related , Time O(n²) → O(n)

→ Better To Store indices of Array

Monotonic Increasing

image.png

increasing matlab jab tak stack ka peek bada ho tab tak pop

Monotonic Decreasing

image.png

decreasing matlab jab tak stack ka peek chota ho tab tak pop

NGE

https://www.youtube.com/watch?v=DtJVwbbicjQ

https://www.youtube.com/watch?v=1_Bbq5qOraY