Data Structures & AlgorithmsVery hard
How many NON-EMPTY subsequences of 2 3 4 7 8 5 (position subsets read in order) alternate in parity, so that each chosen value has the opposite parity to the one before it?
- A. 14
- B. 26
- C. 7
- D. 32
Correct answer: D. 32
Each consecutive pair in the chosen subsequence must have differing parity, which is the parity of their difference being odd. Requiring equal parity, dropping singletons, or requiring only even values each change the set.
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 subsequences of EXACTLY three elements of 1 4 2 5 7 9 6 (position subsets read in order) form an arithmetic progression (the…
- How many NON-EMPTY subsequences of 2 5 3 8 6 1 (subsets chosen by position) have (maximum − minimum) exactly 3?
- 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?