Transform a BST to greater sum tree

Given a BST, transform it into greater sum tree where each node contains sum of all nodes greater than that node.

自己想的复杂了,其实就是一个反向的inorder。新的值就是前面所有元素的求和。

 

posted @ 2014-11-09 14:23  linyx  阅读(152)  评论(0编辑  收藏  举报