思考了一下,发现你的1可以精简为: res= Math.max(result,root.val+leftMax+rightMax); 因为leftMax和rightMax是非负的,所以root.val+leftMax+rightMax一定大于等于root.val+Math.max(leftMax+rightMax)
3

相关推荐

04-24 18:13
南京大学 Java
不吃酸菜血肠:看力竭了
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务