A system has several tasks waiting to be executed. Each task has a unique identifier, a scheduled execution time called runAt, and a priority.
Return the task identifiers in their execution order. Tasks scheduled earlier must execute first. When multiple tasks have the same scheduled time, the task with the higher priority must execute first.
TaskExecutionPlanner
public List<String> getExecutionOrder( List<String> tasks)
tasks contains the task configurations.Every task is represented by a string using the format "taskId,runAt,priority".
taskId is the unique identifier of the task.runAt is the scheduled execution time.priority is the task priority. A larger value represents a higher priority.runAt value executes first.runAt, the task with the larger priority value executes first.taskId executes first.tasks list must not be modified.1 ≤ tasks.size() ≤ 100,000"taskId,runAt,priority" without spaces.1 ≤ taskId.length() ≤ 20taskId contains only lowercase English letters.0 ≤ runAt ≤ 1,000,000,0001 ≤ priority ≤ 1,000,000,000runAt and priority are valid integers.tasks and its elements are never null.getExecutionOrder( tasks = List.of("lint,5,2", "build,2,4", "test,2,8", "deploy,4,7", "docs,5,6"))
Output: List.of("test", "build", "deploy", "docs", "lint")
The tasks scheduled for time 2 execute first, with test before build because it has higher priority. At time 5, docs has higher priority than lint.
getExecutionOrder( tasks = List.of("gamma,7,3", "alpha,7,3", "beta,7,9", "setup,1,1"))
Output: List.of("setup", "beta", "alpha", "gamma")
setup has the earliest scheduled time. Among the tasks scheduled for time 7, beta has the highest priority. The remaining tie is resolved lexicographically.
getExecutionOrder( tasks = List.of("archive,0,1"))
Output: List.of("archive")
The only supplied task is the first and only task executed.