File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
datastructures/trees/binary/tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -694,7 +694,7 @@ def zig_zag_level_order(self) -> List[List[BinaryTreeNode]]:
694694 # we use a queue to traverse the tree level by level
695695 queue = deque ([self .root ])
696696
697- # starting at one , because the root node is already in the result
697+ # starting at zero , because the tree levels are counted from 0
698698 level_number = 0
699699
700700 while queue :
@@ -715,9 +715,9 @@ def zig_zag_level_order(self) -> List[List[BinaryTreeNode]]:
715715 # if level number is odd reverse the list, every odd level is reversed
716716 if level_number % 2 == 1 :
717717 result .append (current_level [::- 1 ])
718-
719- # otherwise add the current level
720- result .append (current_level )
718+ else :
719+ # otherwise add the current level
720+ result .append (current_level )
721721
722722 # add a level and proceed
723723 level_number += 1
You can’t perform that action at this time.
0 commit comments