Atlassian System Design Interview | Snake Game OOD / Implement Move Logic & Game Over Detection

18 Views
No Comments
# n = 20 x 20
# length = 3
# every move -> length + 1
# moves -> 4 directions
# ends if snake hit itself
# snake head at x = 10 y = 10

# interface SnakeGame {#     moveSnake(snakeDirection);
#     isGameOver();
# }

  • Maintain snake body positions in a deque (head at front)
  • Compute new head coordinate based on direction input
  • Check self-collision by testing if the new head already exists in body
  • If collision: mark gameOver = true
  • Otherwise push new head, pop tail (unless growing)

The VOprep team has long accompanied candidates through various major company OAs and VOs, including Meta, Amazon, Citadel, SIG, providing real-time voice assistance, remote practice, and interview pacing reminders to help you stay smooth during critical moments. If you are preparing for these companies, you can check out our customized support plans—from coding interviews to system design, we offer full guidance to help you succeed.

END
 0