Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

A linked list holds 1..8 in order. Reverse the first group of 2 nodes, keep the next group of 2 as is, reverse the next, and so on. What is the resulting order?

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

Correct answer: A. 2 1 3 4 6 5 7 8

Reverse the groups at even group indices only. Reversing every group (the standard k-group reversal) gives a different order.

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

Exams that ask this topic