Coding test/programmers - single
[leetcode] 94. Binary Tree Inorder Traversal
engine
2022. 4. 4. 12:27
def 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)