Data Structures & AlgorithmsModerateCodeforces Div2 B-D · ICPC regional

A circular list holds 1..10. Starting at 1, you count 4 nodes (including the current one) and delete the fourth, then continue counting from the next node. Which node is deleted last?

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

Correct answer: A. 5

Simulate the elimination with an index modulo the remaining length; the last survivor is the last deleted node. Off-by-one in the counting convention moves the answer by one position.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic