lintcode convert bst to greater tree
来源:互联网 发布:软件可靠性分析报告 编辑:程序博客网 时间:2024/06/13 21:15
1.Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST
2.英语不好的我一开始都看不懂啥意思...百度翻译啦啦啦
3./**
* Definition of TreeNode:
* class TreeNode {
* public:
* int val;
* TreeNode *left, *right;
* TreeNode(int val) {
* this->val = val;
* this->left = this->right = NULL;
* }
* }
*/
class Solution {
public:
/**
* @param root the root of binary tree
* @return the new root
*/
int s=0;
TreeNode* convertBST(TreeNode* root) {
// Write your code here
if(root==NULL)return NULL;
convertBST(root->right);
root->val=s+root->val;
s=root->val;
convertBST(root->left);
return root;
}
};
4.一开始完全看不懂题.看了看同学的也完全不懂,感觉特别难,只能看看同学的复制上了......
- lintcode(661)Convert BST to Greater Tree
- LintCode-Convert BST to Greater Tree
- lintcode Convert BST to Greater Tree
- LintCode Convert BST to Greater Tree
- lintcode convert bst to greater tree
- Convert BST to Greater Tree-LintCode
- LintCode Convert BST to Greater Tree
- LintCode 661 Convert BST to Greater Tree
- lintcode——Convert BST to Greater Tree
- LINTCODE——Convert BST to Greater Tree
- Convert BST to Greater Tree
- Convert BST to Greater Tree
- Convert BST to Greater Tree
- Convert BST to Greater Tree
- Convert BST to Greater Tree
- Convert BST to Greater Tree
- Convert BST to Greater Tree
- Convert BST to Greater Tree
- jQuery扩展插件方法----jQuery.extend() 与 jQuery.fn; 以及插件的连缀调用。
- CentOS、Ubuntu、Debian三个linux比较异同
- http请求响应码
- XPath Helper:chrome爬虫网页解析工具 Chrome插件图文教程
- Java中多态实现
- lintcode convert bst to greater tree
- shell 脚本
- PHP中的魔术方法总结 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep
- share all with you
- 2017QZOI游记
- 欢迎使用CSDN-markdown编辑器
- 嵌入式linux——学习笔记
- 【Oracle学习】之 表的连接查询
- 影像管理系统