Leetcode 226. Invert Binary Tree

題目描述:倒置二叉樹、左子樹與右子樹交換。 題目鏈接:Leetcode 226. Invert Binary Tree 題目思路:利用二叉樹的層序遍歷,不斷交換左右子樹,直到最後一層節點。 代碼如下 class Solution: def invertTree(self, root): """ :type root: TreeNode :rtype: TreeNode ""
相關文章
相關標籤/搜索