Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA
What is the sum of lcm(a, b) over all unordered pairs of distinct positions in [2, 3, 4, 6]?
- A. 11
- B. 80
- C. 46
- D. 61
Correct answer: C. 46
Pairs give lcm values 6, 4, 6, 12, 6, 12 in some order, which total 46. The product of the pair is the trap whenever the values share a factor.
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 non-empty subsequences of [2, 3, 5, 7] have a product strictly less than 50?
- In how many ways can [1, 2, 3, 0, 3] be cut into 3 non-empty contiguous parts such that all three parts have equal sum?
- What is the length of the longest contiguous subarray of [1, 5, 6, 2, 8, 3] whose maximum minus minimum is at most 3?
- Meetings occupy the half-open intervals [s, f) listed as (1,2), (3,4), (0,6), (5,7), (8,9), (5,9). Only one meeting may use the room at a…
- Children have greed factors [1, 2, 3] and cookies have sizes [1, 1]. A child is content if assigned a cookie of size at least their greed…
- From the digit string "1432219" remove exactly 3 digits (keeping the remaining digits in their original order) so that the resulting…