Convert BST to Greater Tree
反中序遍历就可以解决了
class Solution(object):
def convertBST(self, root):
"""
:type cur: TreeNode
:rtype: TreeNode
"""
tmp = 0
stack = []
cur = root
while cur or stack:
if cur:
stack.append(cur)
cur = cur.right
else:
cur = stack.pop()
cur.val += tmp
tmp = cur.val
cur = cur.left
return root