Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA
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 time, and a meeting may start exactly when another ends. What is the maximum number of meetings held?
- A. 5
- B. 3
- C. 4
- D. 2
Correct answer: C. 4
Greedy by earliest finish picks (1,2), (3,4), (5,7), (8,9), which is optimal. Sorting by start time would take (0,6) first and lose a meeting.
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
- 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…
- How many contiguous substrings of "abcabc" contain exactly 2 distinct letters?
- How many non-empty contiguous subarrays of [1, 3, 6, 10, 2, 6] have a sum that is a perfect square (including 1, 4, 9, ...)?
- For the binary array [1, 0, 1, 1, 0, 1, 1, 1, 0, 1], you may flip at most 2 zeros to ones. What is the length of the longest run of ones…
- How many distinct strings appear among the rotations of "abab" (all n cyclic shifts, including the unshifted string)?