From a8ac9f9ae075115972ee5bf578890eb4198e4e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lane=20Zhang=20=28=E5=BC=A0=E5=81=A5=29?= Date: Thu, 24 Oct 2024 09:15:07 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E4=BA=8C=E5=8F=89=E6=A0=91=E7=9A=84?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E8=BF=AD=E4=BB=A3=E6=B3=95.md=20=E5=BE=AE?= =?UTF-8?q?=E8=B0=83=20stack=20=E8=B5=8B=E5=80=BC=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/二叉树的统一迭代法.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/problems/二叉树的统一迭代法.md b/problems/二叉树的统一迭代法.md index a1ac9dd2..3a74a932 100644 --- a/problems/二叉树的统一迭代法.md +++ b/problems/二叉树的统一迭代法.md @@ -316,7 +316,7 @@ class Solution: class Solution: def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]: values = [] - stack = [] if root is None else [root] + stack = [root] if root else [] popped_nodes = set() # 用于记录一个节点是否被 pop() 过 while stack: @@ -345,7 +345,7 @@ class Solution: class Solution: def postorderTraversal(self, root: Optional[TreeNode]) -> List[int]: values = [] - stack = [] if root is None else [root] + stack = [root] if root else [] popped_nodes = set() # 用于记录一个节点是否被 pop() 过 while stack: