Data Structures & AlgorithmsModerate

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

  1. A. 19
  2. B. 6
  3. C. 4
  4. D. 3

Correct answer: B. 6

Enumerate subsets and test the spread exactly; the subsets with spread at most three include smaller spreads that must be excluded. Using a weaker bound, neighbouring spreads, or restricting the size each change the total.

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

Exams that ask this topic