Binary Tree Maximum Path Sum
来源:互联网 发布:福州淘宝美工在哪里学 编辑:程序博客网 时间:2024/06/03 15:05
class Solution {public: int maxpath(TreeNode *root,int &maxlocal) { if(root==NULL) return 0; int local=root->val; int left=maxpath(root->left,maxlocal); int right=maxpath(root->right,maxlocal); if(left>0) local=local+left; if(right>0) local=local+right; maxlocal=max(local,maxlocal); return max(max(left,right),0)+root->val; } int maxPathSum(TreeNode *root) { if(root==NULL) return 0; int maxlocal=root->val; maxpath(root,maxlocal); return maxlocal; }};没想到写博客能赚积分,那就多写点。。这题不会,http://blog.csdn.net/sunbaigui/article/details/8980697,估计下次再让我写我还是不会,先留着
0 0
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- Binary Tree Maximum Path Sum
- makefile1
- 潜藏的冷,不觉的就笑了
- iOS 开发百问(1)
- spool命令的使用
- 逗B久了,看到自己就想笑
- Binary Tree Maximum Path Sum
- 【两会大数据】政府工作报告:谁在看?看什么?
- linux平台下RMAN 备份详解
- poj 3243 Clever Y(离散对数-高次同余方程)
- GetSystemMetrics() 函数的用法
- struts2下面如何同时使用servlet,就是如何实现struts与servlet共存
- 微信公众号做一个在线音乐点播功能
- Qt moc文件的作用
- iOS appStore中的应用 实现升级功能2