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,28 @@
Balanced brackets: every step of four inputs
============================================
input: {[()]} firstMismatch = -1
read '{' at 0: push '}' waiting for (top first): }
read '[' at 1: push ']' waiting for (top first): ] }
read '(' at 2: push ')' waiting for (top first): ) ] }
read ')' at 3: pop ')', matches waiting for (top first): ] }
read ']' at 4: pop ']', matches waiting for (top first): }
read '}' at 5: pop '}', matches waiting for (top first): (empty)
end of input: waiting for (empty) -> balanced
input: ([)] firstMismatch = 2
read '(' at 0: push ')' waiting for (top first): )
read '[' at 1: push ']' waiting for (top first): ] )
read ')' at 2: expected ']' -> NOT balanced
input: ()) firstMismatch = 2
read '(' at 0: push ')' waiting for (top first): )
read ')' at 1: pop ')', matches waiting for (top first): (empty)
read ')' at 2: stack is empty, nothing to close -> NOT balanced
input: (() firstMismatch = 0
read '(' at 0: push ')' waiting for (top first): )
read '(' at 1: push ')' waiting for (top first): ) )
read ')' at 2: pop ')', matches waiting for (top first): )
end of input: waiting for ) -> NOT balanced, openers left over