1
var sortColors = function (arr) {
2
let one = 0,
3
zero = 0,
4
two = 0;
5

6
// step1
7
for (let elem of arr) {
8
if (elem == 0) zero++;
9
else if (elem == 1) one++;
10
else two++;
11
}
12

13
// step2
14
arr.length = 0;
15

16
// step3
17
for (let i = 0; i < zero; i++) arr.push(0);
18
for (let i = 0; i < one; i++) arr.push(1);
19
for (let i = 0; i < two; i++) arr.push(2);
20
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0