File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 333 . [ 删除链表中的重复元素] ( https://www.zybuluo.com/Scrazy/note/720542 )
444 . [ 数组中的数组成最小值] ( https://www.zybuluo.com/Scrazy/note/720582 )
555 . [ 索引为index 的丑数] ( https://www.zybuluo.com/Scrazy/note/720587 )
6+ 6 . [ 反转链表] ( https://www.zybuluo.com/Scrazy/note/721436 )
Original file line number Diff line number Diff line change @@ -328,3 +328,27 @@ class Solution:
328328 return True
329329 return is_same(pRoot.left, pRoot.right)
330330```
331+ ### 二叉树镜像
332+
333+ ```
334+ # -*- coding:utf-8 -*-
335+ # class TreeNode:
336+ # def __init__(self, x):
337+ # self.val = x
338+ # self.left = None
339+ # self.right = None
340+ class Solution:
341+ # 返回镜像树的根节点
342+ def Mirror(self, root):
343+ # write code here
344+ if not root:
345+ return None
346+ elif not (root.left or root.right):
347+ return root
348+
349+ root.left, root.right = root.right, root.left
350+ if root.left:
351+ self.Mirror(root.left)
352+ if root.right:
353+ self.Mirror(root.right)
354+ ```
You can’t perform that action at this time.
0 commit comments