Data Structures & AlgorithmsModerate

How many NON-EMPTY subsequences of 1 2 3 5 6 8 9 (subsets chosen by position) have (maximum − minimum) ≤ 2?

  1. A. 16
  2. B. 15
  3. C. 11
  4. D. 8

Correct answer: B. 15

A subsequence is determined by its chosen positions, so every subset of the array is a candidate; the spread test then decides. Including the empty set, using a strict bound, or dropping singletons each change the total.

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

Exams that ask this topic