Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 B
How many index pairs i < j in [1, 2, ..., 10] (the integers 1 to 10) have i * j divisible by 4?
- A. 21
- B. 20
- C. 22
- D. 24
Correct answer: B. 20
The product is divisible by 4 when the two numbers contribute enough factors of 2: either one is divisible by 4, or both are even.
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
- Start with the stack [1]. Operations in order: DUP (push a copy of the top), ADD (pop two and push their sum), DUP, DUP, ADD, ADD. What is…
- Two queues hold [1, 3, 5] and [2, 4, 6]. The output takes one element from the first queue, then one from the second, alternately, until…
- Which technique gives O(1) time per query for 'sum of a[l..r]' on a static array after O(n) preprocessing?
- Given an array that may contain negative numbers, which method counts the subarrays whose sum equals exactly k in O(n) expected time?
- Which structure returns the maximum of every window of size k in a sliding pass in O(n) total time?
- To test whether string s2 is a rotation of string s1 in linear time, which approach is standard?