Data Structures & AlgorithmsModerateGATE CS · TCS NQT
How many contiguous subarrays of [2, 5, 3, 4, 10] have a product divisible by 10?
- A. 10
- B. 7
- C. 9
- D. 12
Correct answer: C. 9
A product is divisible by 10 when it contains a factor 2 and a factor 5. Count subarrays that contain both, using the positions of 5s and even numbers.
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 integers from 1 to 1000 have digit sum exactly 10 and are odd?
- How many ordered pairs (a, b) with 1 <= a, b <= 6 satisfy a b ≡ 1 (mod 7)?
- How many contiguous subarrays of [1, 1, 2, 1, 1] have all elements of the same parity?
- How many index pairs i < j in [1, 3, 4, 7, 8, 10] satisfy |a[j] - a[i]| <= 3?
- How many index triples i < j < k satisfy a[i] + a[j] + a[k] <= 4 for a = [-4, -1, 0, 2, 3, 5]?
- How many windows of length 3 in [1, 2, 3, 1, 2, 2, 4, 1, 3, 4] contain three pairwise distinct values?