# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param root TreeNode类
# @return int整型一维数组
#
import sys
class Solution:
ans=list()
sys.setrecursionlimit(1500)
def inorderTraversal(self , root: TreeNode) -> List[int]:
# 由于python存在最大的递归深度约束,这一步是更改最大深度的限制
# write code here
if root==None:
return None
while root!=None:
self.inorderTraversal(root.left)
# if root.left!=None:
# self.ans.append(root.left)
#直接添加跟节点
self.ans.append(root.val)
self.inorderTraversal(root.right)
# if root.right!=None:
# self.ans.append(root.right)
return self.ans
return self.ans
12-13
220
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-12
327
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-26
214
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)