mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-07 07:35:35 +08:00
Update 二叉树的统一迭代法.md 微调 stack 赋值语句
This commit is contained in:
@ -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:
|
||||
|
Reference in New Issue
Block a user