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

相关推荐

吃饭从不配汤:身高体重可以删掉,四六级可以加粗
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务