Bird
0
0

What is wrong with this turn update logic for 3 players?

medium📝 Analysis Q7 of 15
LLD - Design — Tic-Tac-Toe Game
What is wrong with this turn update logic for 3 players?
current_player = (current_player + 1) % 2
Acurrent_player should decrement instead
BIncrement should be 2, not 1
CModulo should be 3, not 2
DModulo operator is not needed
Step-by-Step Solution
Solution:
  1. Step 1: Check modulo value against player count

    There are 3 players, so modulo should be 3 to cycle correctly.
  2. Step 2: Identify impact of wrong modulo

    Modulo 2 cycles between 0 and 1 only, skipping player 2.
  3. Final Answer:

    Modulo should be 3, not 2 -> Option C
  4. Quick Check:

    Modulo must match player count [OK]
Quick Trick: Modulo equals total players for correct cycling [OK]
Common Mistakes:
MISTAKES
  • Using wrong modulo value
  • Changing increment incorrectly
  • Removing modulo causing overflow

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes