-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
49 lines (39 loc) · 999 Bytes
/
test.js
File metadata and controls
49 lines (39 loc) · 999 Bytes
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
40
41
42
43
44
45
46
47
48
49
function ListNode(val, next) {
this.val = val === undefined ? 0 : val
this.next = next === undefined ? null : next
}
let head = [1, 2, 3, 4, 5]
// function removeElements(head, val) {
// let dummyNode = new ListNode(-1, head)
// let current = dummyNode
// console.log(dummyNode)
// while (current.next !== null) {
// if (current.next.val === val) {
// current.next = current.next.next
// } else {
// current = current.next
// }
// }
// return dummyNode.next
// }
// function middleNode(head) {
// let counter = 0
// let current = head
// while (current.next !== null) {
// counter++
// current = current.next
// }
// let middle = Math.floor(counter / 2)
// let step = 0
// let result = []
// current = head
// while (current.next !== null) {
// if (step >= counter - middle) {
// result.push(head.val)
// }
// current = head.next
// }
// return new ListNode(-1, result).next
// }
// console.log(middleNode(head))
console.log(Math.pow(16, 0.5))