如果将所有的二叉树的路径中的节点值的和的最大值
vector<TreeNode*> g_vec;
int g_max=0;
int maxPathSum(TreeNode *root)
{
if(root!=NULL)
{
g_vec.push_back(root);
if(root->left==NULL&&root->right==NULL)
{
int max=0;
vector<TreeNode*>::iterator itr=g_vec.begin();
for(;itr!=g_vec.end();itr++)
{
cout<<(*itr)->val<<" ";
max+=(*itr)->val;
}
if(g_max<max)
{
g_max=max;
}
cout<<endl;
g_vec.pop_back();
return g_max;
}
maxPathSum(root->left);
maxPathSum(root->right);
g_vec.pop_back();
}
return g_max;
}