Skip to main content

Practice ยท 2 of 3

Urgency Queue with a Heap

Simulate task scheduling with a priority queue: - record Task(String name, int priority) in Solution - static List<String> processTasks(List<Task> tasks, int slots): put all tasks into a PriorityQueue ordered by priority ASCENDING (1 = most urgent), then poll up to slots tasks and return their names in processing order. Same priority โ†’ FIFO among equals (use a sequence tiebreaker in the comparator).

Difficulty: intermediate

Back to lesson: Practice: Collections Lab