牛客网-每日一练
# class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # # # @param root TreeNode类 # @return int整型一维数组 # class Solution: def inorderTraversal(self , root ): if not root: return[] left = self.inorderTraversal(root.left) right = self.inorderTraversal(root.right) return left + [root.val] +right # write code here
给出一棵二叉树,返回这棵树的中序遍历
例如:
给出的二叉树为{1,#,2,3},
1\2/3
返回[1,3,2].