DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
medium
Greedy

Task Assignment (Interval Scheduling)

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Task Assignment (Interval Scheduling)** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Sort tasks + sort machines; greedy assign **Edge Cases to Consider:** - (1) Single machine - (2) All tasks same duration - (3) More machines than tasks

Examples

Example 1
Input: [1,2,3,4,5,6,7,8,9,10], 5 workers
Output: 15
Explanation: Greedy assignment: pair extremes
Example 2
Input: [5,5,5,5], 2 workers
Output: 10
Explanation: Each gets 2 tasks
Example 3
Input: [1], 1 worker
Output: 1
Explanation: Single task

Constraints

  • ▪Input arguments are within valid ranges
  • ▪Optimize for execution speed
  • ▪Handle null/empty inputs gracefully

Watch Out For Edge Cases

  • ▪Single machine
  • ▪All tasks same duration
  • ▪More machines than tasks
Frequently Asked At
AmazonGoogleTCSWipro