Data Structures & AlgorithmsModerate
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 middle value is the mean of the other two)?
- A. 4
- B. 1
- C. 13
- D. 5
Correct answer: A. 4
Three values in order form an arithmetic progression exactly when the outer two sum to twice the middle. Checking the wrong position for the middle, testing divisibility by 3, or a plain sum relation each count different triples.
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 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?
- 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…