Data Structures & AlgorithmsVery hardSSC CGL Tier 2 · Product Company SDE

Problem: Josephus game: n = 37 people stand in a circle numbered 1 to 37. Starting from person 1, every 4th person is removed (counting continues around the circle, skipping removed people). What is the number of the last person left?

  1. A. 34
  2. B. 19
  3. C. 33
  4. D. 1

Correct answer: A. 34

Simulate with index i = (i + k − 1) mod size, removing persons 4, 8, 12, …; the survivor is 34. Counting every 3rd person (stepping k − 1 = 3 as if it were k) gives 19, returning the 0-indexed Josephus recurrence without the + 1 gives 33, and counting every 5th person gives 1.

More Coding Interview Problems questions

Exams that ask this topic