Data Structures & AlgorithmsModerateCodeforces Div2 B-D · ICPC regional

For [1, 3, 2, 4, 6, 5, 7], how many positions already hold their correct value in the sorted array?

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

Correct answer: A. 3

Compare each position with the sorted array; positions 0, 3 and 6 match. The other positions form adjacent transpositions.

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

Exams that ask this topic