Simulation

7 articles

dsa8 min read

Merge Nodes Between Zeros — In-Place Pointer Walk Explained

Learn how to merge all nodes between consecutive zeros in a linked list into a single sum node in O(n) time and O(1) space. A clean simulation problem from LeetCode 2181 that tests in-place pointer manipulation and linked list traversal confidence.

Read →
dsa9 min read

Add Two Numbers — Carry Simulation on Reversed Linked Lists

LC 2 Add Two Numbers is one of the most iconic interview problems at Amazon, Google, and Microsoft where you simulate grade-school addition on two reversed linked lists digit by digit. Master the carry propagation technique with Python and JavaScript solutions, visual dry run, and common pitfalls.

Read →
dsa9 min read

Add Two Numbers II — Stack-Based Reverse-Order Addition Explained

LC 445 Add Two Numbers II is a medium interview problem at Amazon and Google where numbers are stored most-significant-digit first, requiring stacks or list reversal to process from LSB. Learn the optimal stack-based solution with Python and JavaScript, dry run, and the key difference from LC 2.

Read →
dsa7 min read

Baseball Game — Stack Simulation for Record Scoring

Simulate a baseball scoring game using a stack to handle score records, doubles, sum operations, and cancellations in O(n) time. A clean stack-simulation problem that tests your ability to model stateful operations with LIFO access.

Read →