Data Structures & AlgorithmsHard
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 1)?
- A. 6
- B. 3
- C. 1
- D. 2
Correct answer: C. 1
Pairwise coprimality needs all three pairs to have gcd 1, while the gcd of the whole window only tests the triple. Checking distinctness or only one adjacent pair answers a different question.
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 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?
- To count subarrays of length at least 2 with equal odd and even counts, why is the length-1 case excluded?