Data Structures & AlgorithmsHard

How many adjacent pairs (A[i], A[i+1]) in 4 7 2 9 1 8 5 6 have a sum of at least 10?

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

Correct answer: D. 5

Only neighbouring positions form adjacent pairs, so each of the n−1 pairs is checked once. Using a strict bound, counting all index pairs, or using the product instead of the sum gives different totals.

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

Exams that ask this topic