Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

How many adjacent positions in [3, 9, 4, 7, 1] have a[i] > a[i+1]?

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

Correct answer: A. 2

Scan adjacent pairs and count the strict descents. Inversions over all pairs are a different measure, and a sorted run has zero descents.

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

Exams that ask this topic