Data Structures & AlgorithmsVery hardCodeforces Div2 C · TCS NQT
How many unordered pairs of positions in [2, 8, 9, 18, 4, 6, 12] have a product that is a perfect square?
- A. 6
- B. 4
- C. 3
- D. 5
Correct answer: B. 4
Reduce each number to its square-free part: a product is a square exactly when the two square-free parts are equal. Counting pairs whose product is divisible by 4 or by 9 measures a different condition.
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
- For each window of 3 consecutive elements of [1, 2, 1, 3, 2, 1, 4], count the number of DISTINCT values in it. What is the sum of these…
- Repeatedly delete any adjacent pair of letters that are 'a' and 'b' (in either order) from "abbaabbbaab" until none remains. What is the…
- Cards with values [4, 1, 7, 3, 9, 2, 5] lie in a row. In each of 3 moves you take the card at the LEFT end or the RIGHT end. What is the…
- How many ordered sequences of positive integers, each at most 3 and with at least two terms, sum to 6?
- For the array [3, 5, 6, 1], compute the XOR of every non-empty contiguous subarray and add all these XOR values together. What is the total?
- How many non-empty contiguous subarrays of [2, 4, 6, 1, 3, 1, 2, 4] have a bitwise XOR equal to 0?