提交 107b6e01 编写于 作者: L laozhang

add python 114

上级 c412b30b
......@@ -55,6 +55,7 @@
41. [删除给定值的叶子节点](./solution/tree/leetcode_1325_.py)
42. [找树左下角的值](./solution/tree/leetcode_513_.py)
43. [完全二叉树的节点个数](./solution/tree/leetcode_222_.py)
44. [二叉树展开为链表](./solution/tree/leetcode_114_.py)
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# coding=utf-8
"""
114. 二叉树展开为链表
"""
from solution import TreeNode
class Solution:
pre = None
def flatten(self, root: TreeNode) -> None:
"""
Do not return anything, modify root in-place instead.
"""
if not root:
return None
self.flatten(root.right)
self.flatten(root.left)
root.right = self.pre
root.left = None
self.pre = root
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册