Data Structures & AlgorithmsHard
How many subsequences of 1 2 3 4 2 2 (position subsets) of size at least 2 have sum EQUAL to their product?
- A. 12
- B. 6
- C. 8
- D. 7
Correct answer: B. 6
Enumerate subsets of size at least two and compare sum with product; subsets with a 1 mostly fail because multiplying by 1 changes nothing. Allowing singletons, using strict or offset comparisons each change the count.
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
- 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?
- How many contiguous subarrays of 3 5 2 6 1 7 4 8 with length between 2 and 4 inclusive have a sum divisible by 4?
- How many NON-EMPTY subsets of {1, 2, 3, 4, 5, 6} have a sum that is a prime number?
- How many index pairs i < j in 1 2 4 8 9 3 12 6 have a product A[i]·A[j] that is a perfect square?
- How many index triples i < j < k in 2 5 3 8 6 9 4 have A[i] < A[j] < A[k] AND an EVEN total sum?