Data Structures & AlgorithmsHard
How many contiguous windows of length exactly 2 in 2 3 1 4 2 5 0 3 have a PRODUCT strictly greater than their SUM?
- A. 4
- B. 3
- C. 2
- D. 5
Correct answer: B. 3
For two numbers, product exceeds sum exactly when both are at least two and not both equal to two, which the direct test confirms. Using ≥, reversing the comparison, or skipping one position 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
- How many contiguous windows of length exactly 3 in 6 10 15 4 9 7 14 3 have their three values PAIRWISE coprime (every two of them have gcd…
- How many subsequences of EXACTLY three elements of 6 10 15 4 9 (position subsets) have gcd equal to 1?
- How many contiguous windows of length exactly 2 in 4 7 2 9 3 5 11 8 have BOTH values prime?
- Why does the two-transaction stock problem split the array at a point and solve each side independently?
- When the maximum and minimum must end at the two extremes by adjacent swaps, why can their costs interact?
- Why does 'maximum number of disjoint zero-sum blocks' use an interval DP over prefixes rather than a greedy scan?