Data Structures & AlgorithmsHardProduct Company SDE · Amazon OA
Problem: A set of jobs has deadlines and profits: (deadline 1, profit 20), (deadline 2, profit 40), (deadline 2, profit 30), (deadline 3, profit 10). Each job takes one unit and must finish by its deadline. How many jobs can be scheduled in the best selection?
- A. 4
- B. 2
- C. 3
- D. 5
Correct answer: C. 3
Greedy by profit: 40 takes slot 2, 30 takes slot 1 (deadline 2 with slot 2 taken), 20 cannot fit slot 1 (taken) so it is dropped, and 10 takes slot 3. That gives three jobs scheduled.
More Coding Interview Problems questions
- Problem: The insertion sort is applied to [3, 1, 2]. Count the total number of element moves (each shift of an element one place to the…
- Problem: Heap-indexed binary tree with 10 nodes (node i has children 2i and 2i+1 when ≤ 10). How many nodes lie at depth 2 (root at depth…
- Problem: In the sorted array [−3, −1, 0, 1, 2, 3], how many pairs of distinct positions (i < j) have a sum of exactly 0?
- Problem: What is C(10, 3) modulo 7?
- Problem: How many prime numbers lie strictly between 100 and 150?
- Problem: The number of decimal digits in 100! is what value?