Simulation

9 articles

dsa3 min read

Design Snake Game — Deque-Based State Machine

Simulate a snake game on a grid where the snake eats food to grow and dies if it hits walls or itself. Uses a deque for O(1) head/tail and a set for O(1) body collision checks.

Read →