File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -459,11 +459,10 @@ class Solution:
459
459
460
460
queue = collections.deque([root])
461
461
while queue:
462
- for i in range (len (queue)):
463
- node = queue.popleft()
464
- node.left, node.right = node.right, node.left
465
- if node.left: queue.append(node.left)
466
- if node.right: queue.append(node.right)
462
+ node = queue.popleft()
463
+ node.left, node.right = node.right, node.left
464
+ if node.left: queue.append(node.left)
465
+ if node.right: queue.append(node.right)
467
466
return root
468
467
469
468
```
@@ -1033,4 +1032,3 @@ public TreeNode InvertTree(TreeNode root) {
1033
1032
<a href =" https://programmercarl.com/other/kstar.html " target =" _blank " >
1034
1033
<img src =" ../pics/网站星球宣传海报.jpg " width =" 1000 " />
1035
1034
</a >
1036
-
You can’t perform that action at this time.
0 commit comments