Data Structures & AlgorithmsHardTCS NQT · Product Company SDE

Problem: Josephus with step 3: 10 people numbered 1 to 10 stand in a circle. Starting from person 1, count 3 people and eliminate the third, repeating around the shrinking circle until one remains. Who survives?

  1. A. 5
  2. B. 4
  3. C. 3
  4. D. 6

Correct answer: B. 4

Counting three means the eliminated index advances by two from the current person, with wrap-around. Eliminating the second person instead changes the survivor.

More Coding Interview Problems questions

Exams that ask this topic