Leetcode 933 Solution
This article provides solution to leetcode question 933 (increasing-order-search-tree)
Access this page by simply typing in "lcs 933" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/increasing-order-search-tree
Solution
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def reorder(self, root):
if not root:
return
self.reorder(root.left)
root.left = None
self.cur.right = root
self.cur = root
self.reorder(root.right)
def increasingBST(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
ans = self.cur = TreeNode(0)
self.reorder(root)
return ans.right