# Flatten a Linked List (Leetcode 114)

Problem Link: <https://leetcode.com/problems/flatten-binary-tree-to-linked-list/>

```python
class Solution:

    def flatten(self, root: Optional[TreeNode]) -> None:
        
        if(root is None):
            return None
            
        l=self.flatten(root.left)
        r=self.flatten(root.right)
        
        if(l is not None):
            temp=l
            while(temp.right is not None):
                temp=temp.right
            temp.right=r
            root.right=l
        else:
            root.right=r
            
        return root
```
