1
var partition = function (head, x) {
2
if (!head) {
3
return head;
4
}
5
const less = [];
6
const greater = [];
7
let concat;
8
rec(head);
9
return head;
10

11
function rec(currentNode) {
12
if (currentNode.val < x) {
13
less.push(currentNode.val);
14
} else {
15
greater.push(currentNode.val);
16
}
17
if (!currentNode.next) {
18
concat = [...less, ...greater];
19
currentNode.val = concat.pop();
20
return;
21
}
22
rec(currentNode.next);
23
currentNode.val = concat.pop();
24
}
25
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0