Class "Task Tracker" with priorities
TypeScript
Medium
classes
Task «Class "Task Tracker" with priorities»
Implement the TaskTracker class, which manages a list of tasks with priorities (a number from 1 to 5, where 1 is the highest). The class must have the following methods: addTask(id, priority) — adds a task with the specified id (string) and priority; removeTask(id) — removes a task by id; getTask(id) — returns the priority of the task or null if it does not exist; getHighestPriority() — returns the id of the task with the highest priority (smallest number). If there are several such tasks, return the id that was added earlier. If there are no tasks, return null. Implement the methods without using built-in sorting, using a data structure of your choice.
Input Format
First line: number N — the number of commands. Then N lines, each containing a command: add id priority, remove id, get id, highest.
Output Format
For each `get` and `highest` command, output the result on a separate line. For `get` — a number (priority) or `null`, for `highest` — an `id` or `null`.
Examples
Example 1
INPUT
4
add a 5
add b 5
highest
remove a
highest
OUTPUT
a
main.ts