class Solution {
public:
/**
* @param root the root of binary tree
* @return the max node
*/
TreeNode *final;
void look(TreeNode* root)
{
if(root==NULL)
return;
if(final->val<root->val)
{
final=root;
}
look(root->left);
look(root->right);
}
TreeNode* maxNode(TreeNode* root) {
final->val=-10000;
if(root==NULL)
return NULL;
look(root);
return final;
// Write your code here
}
};
水。
二叉树的最大节点 - C++
最新推荐文章于 2023-06-07 15:49:01 发布