dsa2 min read
Basic Calculator I — Stack for Sign and Parentheses
Evaluate a basic expression with +, -, and parentheses using a stack to save and restore sign context.
Read →
webcoderspeed.com
1276 articles
Evaluate a basic expression with +, -, and parentheses using a stack to save and restore sign context.
Design a frequency stack with O(1) push and pop-max-frequency using a map of frequency to stack of elements.
Find the median dynamically as numbers are added using two heaps: a max-heap for the lower half and min-heap for upper.
Serialize a binary tree to a string using BFS level-order and deserialize back using a queue for reconstruction.
Calculate trapped rainwater volume using a monotonic stack that computes water in horizontal layers as bars are processed.