From 48b995a898913f5422fff7d0db632618639cb9f1 Mon Sep 17 00:00:00 2001 From: NYCGithub <35183837+NYCGithub@users.noreply.github.com> Date: Fri, 14 Sep 2018 22:51:50 -0400 Subject: [PATCH] Update binary-tree-right-side-view.py Last node in list is always the right most view. --- Python/binary-tree-right-side-view.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Python/binary-tree-right-side-view.py b/Python/binary-tree-right-side-view.py index 24e427261..6ce57c111 100644 --- a/Python/binary-tree-right-side-view.py +++ b/Python/binary-tree-right-side-view.py @@ -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