Merge pull request #2766 from ZaneCodeJourney/026.Python

0226翻转二叉树,删除冗余代码
This commit is contained in:
程序员Carl
2024-10-21 09:30:11 +08:00
committed by GitHub

View File

@ -459,7 +459,6 @@ class Solution:
queue = collections.deque([root]) queue = collections.deque([root])
while queue: while queue:
for i in range(len(queue)):
node = queue.popleft() node = queue.popleft()
node.left, node.right = node.right, node.left node.left, node.right = node.right, node.left
if node.left: queue.append(node.left) if node.left: queue.append(node.left)
@ -1033,4 +1032,3 @@ public TreeNode InvertTree(TreeNode root) {
<a href="https://programmercarl.com/other/kstar.html" target="_blank"> <a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/> <img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a> </a>