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:
Claude
2026-11-12 22:35:43 +05:30
parent c5c435ae20
commit b9aeb78b24
36 changed files with 2164 additions and 0 deletions
@@ -0,0 +1,19 @@
java.util.Stack versus ArrayDeque used as a stack
=================================================
ArrayDeque as a stack: push(1), push(2), push(3), then pop until empty -> [3, 2, 1]
ArrayDeque as a queue: offer(1), offer(2), offer(3), then poll until empty -> [1, 2, 3]
push(1), push(2), push(3), then iterate:
java.util.Stack -> [1, 2, 3] (bottom to top)
ArrayDeque -> [3, 2, 1] (top to bottom)
Stack.class.getSuperclass() = java.util.Vector
Stack.pop() is synchronized = true
ArrayDeque.pop() is synchronized = false
push(null) on Stack = accepted
push(null) on ArrayDeque = java.lang.NullPointerException
ArrayDeque: push(1), push(2), peek() = 2 (push is addFirst)
ArrayDeque: offer(1), offer(2), peek() = 1 (offer is addLast)