-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
39 lines (29 loc) · 678 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function createList(arr) {
class ListNode {
constructor(val, next) {
this.val = (val === undefined ? 0 : val)
this.next = (next === undefined ? null : next)
}
}
let head = new ListNode(arr[0]);
let start = head;
for (let i = 1; i < arr.length; i++) {
start.next = new ListNode(arr[i]);
start = start.next;
}
return head;
}
function test(arr) {
let list = insertionSortList(createList(arr));
const arr = [];
while (list) {
arr.push(list.val);
list = list.next;
}
return list;
}
function insertionSortList(head) {
let initialHead = head;
}
console.log(format([4,2,1,3]));
console.log(format([-1,5,3,4,0]));