Amazon·Software Engineer·Technical Phone Screen
- You have a daily task limit, a list of required tasks per day, and a shared pool of optional tasks. Each day you must complete its required task, and if time allows you can schedule at most one optional task from the pool (each optional used at most once). How do you maximize the number of optional tasks scheduled, and how do you reconstruct a valid assignment?
- How would your approach change if each optional task could only be scheduled on its corresponding day, meaning optional[i] is only eligible for day i?
- What happens when some required tasks exceed the daily limit? How do you handle that edge case?
- How would you generalize the solution if each day could accommodate up to k optional tasks instead of just one?
“This is a greedy problem.”