Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div2 B
How many contiguous subarrays of [1, 2, 3, 4, 6, 2] have a product exactly equal to 12?
- A. 3
- B. 4
- C. 2
- D. 6
Correct answer: C. 2
Enumerate all subarrays and check each product; the answer counts every window whose product is exactly 12, including the windows that contain the value 1 only when the product still matches.
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 index pairs i < j in [1, 2, 3, 4, 5, 6, 7, 8] have equal parity and a[i] + a[j] <= 10?
- What is the length of the longest substring of aabbbcca in which every letter occurs at most twice?
- How many palindromic substrings of length 3 or more does racecar contain (counted by position)?
- How many distinct rotations does the string aabaab have (including itself)?
- What is the sum of all positive divisors of 28, a perfect number?
- How many integers in [1, 100] have exactly two distinct prime factors (counted without multiplicity)?