Binary Tree Maximum Node
来源:互联网 发布:unity3d的web控件 编辑:程序博客网 时间:2024/05/29 14:48
Find the maximum node in a binary tree, return the node.
Given a binary tree:
1 / \ -5 2 / \ / \0 3 -4 -5
return the node with value 3
.
class Solution {public: /** * @param root the root of binary tree * @return the max node */ TreeNode* b = new TreeNode(-10000); void Node(TreeNode* root) { if (root == NULL) { return; } if (root->val > b->val) { b = root; } Node(root->left); Node(root->right); } TreeNode* maxNode(TreeNode* root) { // Write your code here if (root == NULL) { return NULL; } Node(root); return b; }};
0 0
- Binary Tree Maximum Node
- Binary Tree Maximum Node
- LintCode | 632. Binary Tree Maximum Node
- [LintCode]Binary Tree Maximum Node(C++)
- LintCode-632.Binary Tree Maximum Node
- [Lintcode] 632. Binary Tree Maximum Node
- 654. Maximum Binary Tree
- 654. Maximum Binary Tree
- Leetcode654. Maximum Binary Tree
- leetcode654: Maximum Binary Tree
- 654. Maximum Binary Tree
- 654. Maximum Binary Tree
- LeetCode Maximum Binary Tree
- 654. Maximum Binary Tree
- Maximum Binary Tree
- Maximum Binary Tree
- Maximum Binary Tree
- 654. Maximum Binary Tree
- 1016. 部分A+B (15) python篇
- matlab常用函数
- 自定义圆形头像
- Linux常用操作指令
- 嵌入式笔试题目
- Binary Tree Maximum Node
- CEdit添加鼠标事件处理
- TCP/IP基础(一)
- 计算机常用的英语术语(不定时更新)
- Java实现excel简单的读写操作
- 1017. A除以B (20) python篇
- 数字三角形问题
- 关于c++中的拷贝构造函数(复制构造函数)
- IRC 服务以及freenode