# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None class Solution(object):
def inorderTraversal(self, root):
"""
:type root: TreeNode
:rtype: List[int]
"""
res=[]
stk=[]
if root == None:
return res
while root != None or len(stk) != 0:
if root != None:
stk.append(root)
root=root.left
elif len(stk) != 0:
tmpNode=stk.pop()
res.append(tmpNode.val)
root=tmpNode.right
return res
相关文章
- 03-26leetcode Binary Tree Inorder Traversal python
- 03-26leetcode [701. 二叉搜索树中的插入操作](https://leetcode-cn.com/problems/insert-into-a-binary-search-tree/)
- 03-26LeetCode:145_Binary Tree Postorder Traversal | 二叉树后序遍历 | Hard
- 03-26[LeetCode]题解(python):105-Construct Binary Tree from Preorder and Inorder Traversal
- 03-26LeetCode - Minimum Depth of Binary Tree
- 03-26Leetcode#145 Binary Tree Postorder Traversal
- 03-26[LeetCode145]Binary Tree Postorder Traversal
- 03-26Leetcode_114_Flatten Binary Tree to Linked List
- 03-26[LeetCode] 105. Construct Binary Tree from Preorder and Inorder Traversal_Medium tag: Tree Traversal
- 03-2619.3.5 [LeetCode 104] Maximum Depth of Binary Tree