Data Structures & AlgorithmsModerate
How many NON-EMPTY subsequences of 2 5 3 8 6 1 (subsets chosen by position) have (maximum − minimum) exactly 3?
- A. 19
- B. 6
- C. 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.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many NON-EMPTY subsets of 1 2 3 4 5 6 7 have bitwise XOR equal to 0?
- How many subsets of exactly two elements of 2 4 5 7 9 10 12 (position pairs) have a sum divisible by 3?
- How many subsequences of EXACTLY four elements of 1 2 3 4 5 6 7 (position subsets) sum to 16?
- How many subsequences of 1 2 3 4 2 2 (position subsets) of size at least 2 have sum EQUAL to their product?
- Remove the MINIMUM possible number of elements from 4 3 5 2 6 so that the remaining elements have a sum of at most 10. How many different…
- How many subsequences of exactly three elements of 1 6 4 9 5 3 (position subsets) have a sum divisible by 5?