Skip to content

Commit e475efe

Browse files
authored
Merge pull request kamyu104#32 from sangheestyle/flatten-binary-tree-to-linked-list.py
update flatten-binary-tree-to-linked-list.py
2 parents 33ca493 + f754d62 commit e475efe

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Python/flatten-binary-tree-to-linked-list.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ class Solution(object):
1111
# @param root, a tree node
1212
# @return nothing, do it in place
1313
def flatten(self, root):
14-
return self.flattenRecu(root, None)
14+
self.flattenRecu(root, None)
1515

1616
def flattenRecu(self, root, list_head):
17-
if root != None:
17+
if root:
1818
list_head = self.flattenRecu(root.right, list_head)
1919
list_head = self.flattenRecu(root.left, list_head)
2020
root.right = list_head
@@ -28,11 +28,9 @@ class Solution2(object):
2828
# @param root, a tree node
2929
# @return nothing, do it in place
3030
def flatten(self, root):
31-
if root != None:
31+
if root:
3232
self.flatten(root.right)
3333
self.flatten(root.left)
3434
root.right = self.list_head
3535
root.left = None
3636
self.list_head = root
37-
return root
38-

0 commit comments

Comments
 (0)