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