Skip to content

Commit

Permalink
Merge pull request #162 from NYCGithub/patch-6
Browse files Browse the repository at this point in the history
Update binary-tree-right-side-view.py
  • Loading branch information
kamyu104 authored Sep 15, 2018
2 parents 5810b7e + 48b995a commit 2eff7e0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Python/binary-tree-right-side-view.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ def rightSideView(self, root):
result, current = [], [root]
while current:
next_level = []
for i, node in enumerate(current):
for node in current:
if node.left:
next_level.append(node.left)
if node.right:
next_level.append(node.right)
if i == len(current) - 1:
result.append(node.val)
next_level.append(node.right)
result.append(node.val)
current = next_level

return result

0 comments on commit 2eff7e0

Please sign in to comment.