A task list gives each task a priority level from 0 (most urgent) to 4. tasks holds pairs [name, level] in the order they were created.
Write byPriority(tasks) that returns the task names ordered by level, most urgent first. Tasks with the same level must stay in the order they were created.
Input: tasks = [["deploy",1],["fix login",0],["write docs",3],["review",1]] Output: ["fix login","deploy","review","write docs"]
Level 0 first, then the two level 1 tasks in their original order, then level 3.
Input: tasks = [["a",2],["b",2]] Output: ["a","b"]
Same level: keep the original order.
0 <= tasks.length <= 1000000 <= level <= 4Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #203 Group Tasks by Priority Level. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.