🧠 Simulation Problems – Frequently Asked
(Interview Focused)
Simulation problems test your ability to follow rules exactly, handle edge cases, and code cleanly.
These are VERY common in FAANG, product companies, and OA rounds.
🔹 What is a Simulation Problem?
A problem where:
Rules are clearly defined
No formula / DP / trick initially
You simulate step-by-step exactly as described
👉 If you miss one rule = WA ❌
🧩 Core Simulation Patterns
1. Array modification
2. Pointer movement
3. Process execution
4. Queue / Stack based simulation
5. State tracking
6. Time-step simulation
1️⃣ Array-Based Simulation
🔸 3507. Minimum Pair Removal to Sort Array I
Pattern: Forced Greedy + Simulation
Always merge adjacent pair with minimum sum
Repeat until array becomes non-decreasing
📌 Key idea: No choice → just simulate
🔸 66. Plus One
Pattern: Carry Simulation
Add 1 from last digit
Handle carry propagation
🔸 989. Add to Array-Form of Integer
Pattern: Manual addition
Simulate digit-by-digit addition
🔸 495. Teemo Attacking
Pattern: Interval simulation
Merge overlapping poison intervals
2️⃣ Pointer Movement Simulation
🔸 682. Baseball Game
Pattern: Stack Simulation
Follow operations one by one
Undo / duplicate / sum
🔸 844. Backspace String Compare
Pattern: Backspace simulation
Process characters sequentially
🔸 283. Move Zeroes
Pattern: Two-pointer simulation
Shift non-zero values forward
3️⃣ Queue / Process Simulation
🔸 933. Number of Recent Calls
Pattern: Sliding Window + Queue
Remove outdated timestamps
🔸 1700. Number of Students Unable to Eat Lunch
Pattern: Queue rotation simulation
Circular behavior
Stop condition critical ⚠️
🔸 2073. Time Needed to Buy Tickets
Pattern: Queue simulation
Each second = one ticket sold
4️⃣ Grid / Direction Simulation
🔸 874. Walking Robot Simulation
Pattern: Direction + obstacle handling
Turn left/right
Move step by step
🔸 657. Robot Return to Origin
Pattern: Position tracking
(x, y) coordinate updates
🔸 1706. Where Will the Ball Fall
Pattern: Grid slope simulation
Track each ball independently
5️⃣ State Change Simulation
🔸 289. Game of Life
Pattern: State transition
Apply rules simultaneously
Use temporary states
🔸 999. Available Captures for Rook
Pattern: Direction scan simulation
Move in 4 directions until blocked
6️⃣ Time-Step Simulation
🔸 649. Dota2 Senate
Pattern: Round-based simulation
Track bans across rounds
🔸 2383. Minimum Hours of Training to Win a Competition
Pattern: Resource simulation
Increment power/energy as needed
7️⃣ Stack-Based Simulation
🔸 735. Asteroid Collision
Pattern: Stack + direction simulation
Compare sizes
Multiple pops possible
🔸 946. Validate Stack Sequences
Pattern: Push/pop simulation
Exact operation order matters
8️⃣ Tricky Interview Simulation (High Value)
🔸 1169. Invalid Transactions
Pattern: Rule-based simulation
Time window
Same name, different cities
🔸 609. Find Duplicate File in System
Pattern: Parsing + simulation
Extract content
Group paths
🔸 1243. Array Transformation
Pattern: Repeated transformation
Apply rules until stable
🧠 How to Identify a Simulation Problem?
Ask yourself:
Are rules explicitly given?
Do I need to "do what the problem says"?
No formula, no optimization initially?
👉 If YES → Simulation
🛠️ General Simulation Template (JavaScript)
while (conditionNotMet) {
// 1. find required element / state
// 2. apply operation
// 3. update answer / state
}