FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithms/tree/binary_tree_paths.py at master · QinTuCoding/algorithms · GitHub
QinTuCoding
/
algorithms
Public
forked from
keon/algorithms
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithms
/
tree
/
binary_tree_paths.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
14 lines (13 loc) · 369 Bytes
Breadcrumbs
algorithms
/
tree
/
binary_tree_paths.py
Copy path
File metadata and controls
14 lines (13 loc) · 369 Bytes
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
def
binaryTreePaths
(
root
):
res
=
[]
if
not
root
:
return
res
DFS
(
res
,
root
,
str
(
root
.
val
))
return
res
def
DFS
(
res
,
root
,
cur
):
if
not
root
.
left
and
not
root
.
right
:
res
.
append
(
cur
)
if
root
.
left
:
DFS
(
res
,
root
.
left
,
cur
+
'->'
+
str
(
root
.
left
.
val
))
if
root
.
right
:
DFS
(
res
,
root
.
right
,
cur
+
'->'
+
str
(
root
.
right
.
val
))
Back
|
FazBrowse Home
|
New Git URL