A deploy pipeline view tags each job with a level from 0 to 3: 0 failed, 1 running, 2 queued, 3 passed. The view lists jobs from level 0 up to level 3.
Write sortLevels(levels) that sorts levels in place with O(1) extra memory, without calling sort and without counting how many of each level there are. The tests check levels after your function runs.
Input: levels = [3,1,0,2,3,0] Output: [0,0,1,2,3,3]
Failed jobs first, then running, queued, and passed.
Input: levels = [2,1] Output: [1,2]
Two middle levels swap.
0 <= levels.length <= 1000000, 1, 2, or 3.Run 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 #122 Sort Four Status Levels. 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.