##### python默认的递归深度是很有限的,大概是900多的样子,当递归深度超过这个值的时候,就会引发这样的一个异常:RuntimeError: maximum recursion depth exceeded。
import sys sys.setrecursionlimit(100000) #例如这里设置为一百万 class Solution: def inorderTraversal(self , root: TreeNode) -> List[int]: # write code here res = [] def midorder(root): if root is None: return res midorder(root.left) res.append(root.val) midorder(root.right) midorder(root) return res