Data Structures & AlgorithmsHardGATE CS · TCS NQT
How many windows of size 3 in [2, 3, 5, 1, 4, 6, 4] have a sum that is a multiple of 5?
- A. 3
- B. 2
- C. 1
- D. 4
Correct answer: B. 2
Sliding window sums update in O(1) per step; checking each window sum modulo 5 gives the count. Windows like 2+3+5 = 10 qualify.
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
- Sum the popcount of a[i] AND a[j] over all index pairs i < j of [7, 11, 13]. What is the total?
- What is the minimum number of characters that must be deleted from the binary string "1101001110" so that no two adjacent characters are…
- People 1 to 10 stand in a circle. Starting from person 1, every second person is eliminated until one remains. Who survives?
- How many unordered pairs {x, y} of distinct integers from 1 to 20 have x + y divisible by 5?
- For "dcbadcba", among its rotations, which starting index i (0-based, the rotation s[i:] + s[:i]) gives the lexicographically smallest…
- What is the maximum nesting depth of parentheses in "(()(()))()"?