IT_World
[leetcode] 94. Binary Tree Inorder Traversal 본문
Coding test/programmers - single
[leetcode] 94. Binary Tree Inorder Traversal
engine 2022. 4. 4. 12:27def inorderTraversal(self, root: TreeNode) -> List[int]:
stack = [root]
res = []
while stack:
node = stack.pop()
if node:
stack.append(node.right)
stack.append(node)
stack.append(node.left)
else:
if stack:
node = stack.pop()
res.append(node.val)
'Coding test > programmers - single' 카테고리의 다른 글
[leetcode] 64. Minimum Path Sum (0) | 2022.04.06 |
---|---|
[leetcode] 62. Unique Paths (0) | 2022.04.04 |
[leetcode] 83. Remove Duplicates from Sorted List (0) | 2022.04.03 |
[leetcode] 88. Merge Sorted Array (0) | 2022.04.03 |
[leetcode] 70. Climbing Stairs (0) | 2022.04.02 |
Comments