> For the complete documentation index, see [llms.txt](https://zcjian.gitbook.io/project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zcjian.gitbook.io/project/tree/flatten-binary-tree-to-linked-list.md).

# Flatten Binary Tree to Linked List

LeetCode 114

```python
# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None

class Solution:
    def __init__(self):
        self.tmp = None
        
    def flatten(self, root):
        """
        :type root: TreeNode
        :rtype: void Do not return anything, modify root in-place instead.
        """
                
        if not root:
            return
        self.flatten(root.right)
        self.flatten(root.left)

        root.right = self.tmp
        root.left = None
        self.tmp = root
```
