deno.land / x / masx200_leetcode_test@10.6.5 / clone-n-ary-tree / test.ts

نووسراو ببینە
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import { assert, assertEquals } from "../deps.ts";import { Node } from "../n-ary-tree-level-order-traversal/Node.ts";import cloneTree from "./index.ts";
Deno.test("clone-n-ary-tree-0", () => { const root = { val: 10, children: [ { val: 20, children: [], }, { val: 21, children: [ { val: 200, children: [], }, ], }, { val: 19, children: [], }, ], }; // const three =;
// root.children.push(three); // root.children.push(new Node(2)); // root.children.push(new Node(4)); // three.children.push(new Node(5)); // three.children.push(new Node(6)); const cloned = cloneTree(root); assert(cloned !== root); assertEquals(JSON.stringify(root), JSON.stringify(cloned)); // console.log(JSON.stringify(cloned)) // console.log(root)});Deno.test("clone-n-ary-tree-1", () => { const root = new Node(1, [ new Node(3, [new Node(5), new Node(6)]), new Node(2), new Node(4), ]); // const three =;
// root.children.push(three); // root.children.push(new Node(2)); // root.children.push(new Node(4)); // three.children.push(new Node(5)); // three.children.push(new Node(6)); const cloned = cloneTree(root); assert(cloned !== root); assertEquals(root, cloned); // console.log(JSON.stringify(cloned)) // console.log(root)});
Deno.test("clone-n-ary-tree-2", () => { const root: Node = new Node(1, [ new Node(2), new Node(3, [new Node(6), new Node(7, [new Node(11, [new Node(14)])])]), new Node(4, [new Node(8, [new Node(12)])]), new Node(5, [new Node(9, [new Node(13)]), new Node(10)]), ]);
const cloned = cloneTree(root); assert(cloned !== root); assertEquals(root, cloned); // assertEquals(JSON.stringify(root), JSON.stringify(cloned)); // console.log(JSON.stringify(cloned)) // console.log(root)});
Deno.test("clone-n-ary-tree-3", () => { const root: Node = new Node(1, [ new Node(3, [new Node(5), new Node(6)]), new Node(2), new Node(4, [ new Node(13, [ new Node(15), new Node(16, [ new Node(43, [ new Node(25), new Node(26, [ new Node(14, [ new Node(23, [ new Node(45), new Node(46, [ new Node(33, [ new Node(35), new Node(36), ]), ]), ]), ]), ]), ]), ]), ]), ]), ]);
const cloned = cloneTree(root); assert(cloned !== root); assertEquals(root, cloned); // assertEquals(JSON.stringify(root), JSON.stringify(cloned)); // console.log(JSON.stringify(cloned)) // console.log(root)});
masx200_leetcode_test
leetcode题解和一些测试工具
DocumentationDocumentation
GitHub Repositorymasx200/leetcode-test
GitHub Stars
4

Version Info

Tagged at
4 months ago