Data Structures & AlgorithmsHardProduct Company SDE · Amazon OA
Problem: Video clips of the form [start, end] cover the interval [0, 10]. The clips are [0,2], [4,6], [8,10], [1,9], [2,5], [5,7]. What is the minimum number of clips needed to cover [0, 10] completely?
- A. 3
- B. 4
- C. 2
- D. 5
Correct answer: A. 3
Greedy coverage: from the current end, extend with the clip that starts before it and reaches farthest. Taking the first clip that starts at the current end can waste a clip.
More Coding Interview Problems questions
- Problem: The stock span of a day is the number of consecutive days (including today) up to and including today with a price at most…
- Problem: Five customers with service times 5, 3, 8, 2, 4 (in arrival order) are served by two tellers. Each customer goes to whichever…
- Problem: How many ordered pairs (a, b) of positive integers satisfy a × b = 36 with a ≤ 100 and b ≤ 100?
- Problem: How many non-negative integer solutions (x, y, z) satisfy x + y + z = 10?
- Problem: How many integer solutions (x, y, z) with x, y, z ≥ 1 satisfy x + y + z = 10?
- Problem: A derangement is a permutation with no fixed point. How many derangements of 5 objects exist?