Data Structures & AlgorithmsModerateGATE CS · TCS NQT
How many elements of the array [6, 12, 18, 24, 30] are divisible by at least one element that appears before them in the array?
- A. 4
- B. 5
- C. 3
- D. 6
Correct answer: A. 4
Check each element against all earlier ones; the first element has no predecessor and does not count. Dividing by the element itself is excluded.
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
- From [4, -2, 7, 1, -5, 3, 8, 2], choose a window of 4 consecutive elements, then remove exactly one element from that window. What is the…
- How many index pairs i < j in [5, 2, 8, 3, 1, 9] satisfy a[i] a[j] <= 15?
- What is the sum of the minimum element over all contiguous subarrays of [5, 3, 4, 2] that have length at least 2?
- Meetings are half-open intervals [s, e) listed as (1,4), (2,5), (3,6), (7,9), (8,10), (5,7). A meeting ending at time t and another…
- What is the smallest positive integer n such that 1 + 2 + ... + n is at least 500?
- What is the minimum number of elements to delete from [4, 9, 1, 6, 3, 8] so that the remaining elements have maximum minus minimum at most…