Add stack-queue module: ten stack and queue interview problems, monotonic stack, min stack, queue from stacks and stack from a queue, brute-force cross-checks, dry-run traces, operation counts, pitfalls (11 tests)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6nxynun5JFivebVb1
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
Min stack: both internal stacks after every operation
|
||||
=====================================================
|
||||
|
||||
push 5 values=[5] mins=[5] (new or equal minimum, also pushed on mins)
|
||||
push 3 values=[3, 5] mins=[3, 5] (new or equal minimum, also pushed on mins)
|
||||
push 7 values=[7, 3, 5] mins=[3, 5]
|
||||
push 3 values=[3, 7, 3, 5] mins=[3, 3, 5] (new or equal minimum, also pushed on mins)
|
||||
getMin values=[3, 7, 3, 5] mins=[3, 3, 5] getMin() = 3
|
||||
pop -> 3 values=[7, 3, 5] mins=[3, 5] (it was the minimum, mins popped too)
|
||||
getMin values=[7, 3, 5] mins=[3, 5] getMin() = 3
|
||||
pop -> 7 values=[3, 5] mins=[3, 5]
|
||||
getMin values=[3, 5] mins=[3, 5] getMin() = 3
|
||||
pop -> 3 values=[5] mins=[5] (it was the minimum, mins popped too)
|
||||
getMin values=[5] mins=[5] getMin() = 5
|
||||
|
||||
getMin results: [3, 3, 3, 5] (identical for MinStack and EncodedMinStack)
|
||||
Reference in New Issue
Block a user