-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4-2.js
63 lines (51 loc) · 1.02 KB
/
4-2.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* TODO:
* Testing
* Debugging
*/
function toString(list) {
let head = list;
let str = '';
while (head !== null) {
str = `${head.value}${str}`;
head = head.next;
}
return str;
}
function sumLists(list1, list2) {
let num1 = parseInt(toString(list1), 10);
let num2 = parseInt(toString(list2), 10);
return num1 + num2;
}
function makeList(values = []) {
let current = {
value: values.shift(),
next: null
};
const head = current;
values.forEach(value => {
next = {
value,
next: null
}
current.next = next;
current = next;
});
return head;
}
function test(str){
const stack = [];
let index = 0;
let length = str.length
while(index < length){
let char = str[index];
}
}
testValid("{}");
testValid("[]");
testValid("()");
testValid("([{}])");
testInvalidValid("())");
testInvalidValid("(()");
testInvalidValid("[}]");
testInvalidValid("{[()][]{}");