思路:遞歸
class Solution(object):
def flatten(self, root):
"""
:type root: TreeNode
:rtype: None Do not return anything, modify root in-place instead.
"""
r = root
if not root:
return
right = root.right
root.right = Solution().flatten(root.left)
root.left = None
while root.right:
root = root.right
root.right = Solution().flatten(right)
return r