# Increasing Order Search Tree (Leetcode 897)

Problem Link: <https://leetcode.com/problems/increasing-order-search-tree/>

```python
class Solution:
    
    def lastNode(root):
        if(root is None):
            return None
        temp=root
        while(1):
            if(temp.right is None):
                break
            temp=temp.right
        return temp
    
    def increasingBST(self, root: TreeNode) -> TreeNode:
           
        if(root is None):
            return None
        if(root.left is not None):
            l=self.increasingBST(root.left)
            temp=l
            root.left=None
        else:
            temp=None
            root.left=None
        if(root.right is not None):
            r=self.increasingBST(root.right)
            root.right=r
        else:
            root.right=None
        lastnode=Solution.lastNode(temp)
        if(lastnode is None):
            return root
        else:
            lastnode.right=root
            return temp
```
