FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithm/Week_02/id_117/LeetCode_938_117_test.go at master · feixiangcode/algorithm · GitHub
feixiangcode
/
algorithm
Public
forked from
algorithm001/algorithm
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithm
/
Week_02
/
id_117
/
LeetCode_938_117_test.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
74 lines (64 loc) · 1.36 KB
Breadcrumbs
algorithm
/
Week_02
/
id_117
/
LeetCode_938_117_test.go
Copy path
File metadata and controls
74 lines (64 loc) · 1.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package
solution
import
(
"testing"
)
func
initializeTree938_01
()
*
TreeNode
{
/*
Input: root = [10,5,15,3,7,null,18], L = 7, R = 15
Output: 32
*/
root
:=
createNode
(
10
)
node1
:=
createNode
(
5
)
node2
:=
createNode
(
15
)
node3
:=
createNode
(
3
)
node4
:=
createNode
(
7
)
node5
:=
createNode
(
18
)
root
.
Left
=
node1
root
.
Right
=
node2
node1
.
Left
=
node3
node1
.
Right
=
node4
node2
.
Right
=
node5
return
root
}
func
initializeTree938_02
()
*
TreeNode
{
/*
Input: root = [10,5,15,3,7,13,18,1,null,6], L = 6, R = 10
Output: 23
*/
root
:=
createNode
(
10
)
node1
:=
createNode
(
5
)
node2
:=
createNode
(
15
)
node3
:=
createNode
(
3
)
node4
:=
createNode
(
7
)
node5
:=
createNode
(
18
)
node6
:=
createNode
(
13
)
node7
:=
createNode
(
1
)
node8
:=
createNode
(
6
)
root
.
Left
=
node1
root
.
Right
=
node2
node1
.
Left
=
node3
node1
.
Right
=
node4
node2
.
Left
=
node6
node2
.
Right
=
node5
node3
.
Left
=
node7
node4
.
Left
=
node8
return
root
}
func
TestLeetCode_938_117
(
t
*
testing.
T
) {
root01
:=
initializeTree938_01
()
root02
:=
initializeTree938_02
()
arrs
:=
make
(
map
[
*
TreeNode
]
int
,
0
)
arrs
[
root01
]
=
32
arrs
[
root02
]
=
23
anwsers
:=
make
(
map
[
*
TreeNode
][]
int
,
0
)
anwsers
[
root01
]
=
[]
int
{
7
,
15
}
anwsers
[
root02
]
=
[]
int
{
6
,
10
}
for
k
,
v
:=
range
arrs
{
rangeSum
:=
rangeSumBST
(
k
,
anwsers
[
k
][
0
],
anwsers
[
k
][
1
])
if
rangeSum
==
v
{
t
.
Log
(
"TRUE"
)
}
else
{
t
.
Error
(
"FALSE"
)
}
}
}
Back
|
FazBrowse Home
|
New Git URL