Problem Statement
In a high-intensity coding environment, "Context Switching" is the biggest productivity killer. You are tasked with building a Task Priority Scheduler that mimics a smart VS Code extension. The scheduler must manage tasks based on their urgency and estimatedTime, but it must also implement a "Cool Down" period to prevent developer burnout.
Implement a class TaskScheduler with the following requirements:
addTask(task): Adds a task object{ id, urgency, estimatedTime }to the queue.getNextTask(): Returns the task with the highesturgency. If two tasks have the same urgency, return the one with the shortestestimatedTime(Shortest Job First).completeTask(id): Marks a task as completed. After a task is completed, no new task can be started for a "Cool Down" period of 10ms perestimatedTimeunit of the completed task.isAvailable(): Returnstrueif the developer is not in a cool-down period,falseotherwise.
Example
Constraints
- 0 <= urgency <= 10
- estimatedTime is in milliseconds.
- The scheduler should handle up to 1000 tasks.