dsa2 min read
Valid Parentheses — Stack Bracket Matching
Check if a string of brackets is valid by pushing open brackets and matching close brackets against the stack.
Read →
1575 articles
Check if a string of brackets is valid by pushing open brackets and matching close brackets against the stack.
Implement a stack using one queue by rotating all elements after each push to bring the new element to the front.
Implement a queue using two stacks with amortized O(1) operations by lazily transferring from inbox to outbox.
Design a stack with O(1) getMin by maintaining a parallel min-tracking stack alongside the main stack.
Simulate a baseball scoring game using a stack to track valid scores and handle +, D, and C operations.