Leetcode 226. Invert Binary Tree

题目描述:倒置二叉树、左子树与右子树交换。 题目链接:Leetcode 226. Invert Binary Tree 题目思路:利用二叉树的层序遍历,不断交换左右子树,直到最后一层节点。 代码如下 class Solution: def invertTree(self, root): """ :type root: TreeNode :rtype: TreeNode ""
相关文章
相关标签/搜索