摘要:
本次使用的递归思想是非常基础且重要的。思路就是首先从数组的中间位置建立跟节点,然后元素左边的递归建立左子树,元素右边递归建立右子树。 1 class Solution: 2 def sortedArrayToBST(self, nums: List[int]) -> TreeNode: 3 if n 阅读全文
摘要:
leetcode 226翻转二叉树(剑指offer.二叉树的镜像) 初级递归 1 class Solution: 2 def invertTree(self, root: TreeNode) -> TreeNode: 3 if not root: 4 return 5 root.left,root. 阅读全文