原文:[LeetCode] 112. Path Sum 二叉樹的路徑和

Given a binary tree and a sum, determine if the tree has a root to leaf path such that adding up all the values along the path equals the given sum. Note:A leaf is a node with no children. Example: G ...

2014-10-20 13:08 4 12704 推薦指數:

查看詳情

[LeetCode 124] - 二叉樹最大路徑和(Binary Tree Maximum Path Sum)

問題 給出一個二叉樹,找到其中的最大路徑和。 路徑可以從樹中任意一個節點開始和結束。 例如: 給出如下二叉樹, 1 / \ 2 3 返回6。 初始思路 為了簡化分析,我們先假設二叉樹中所有節點的值都是正數。通過觀察可以發現,一棵 ...

Sun Jun 09 06:02:00 CST 2013 0 4343
[LeetCode] Binary Tree Paths 二叉樹路徑

們一個二叉樹,讓我們返回所有根到葉節點的路徑,跟之前那道Path Sum II很類似,比那道稍微簡單一些, ...

Tue Aug 18 06:45:00 CST 2015 5 11424
二叉樹系列 - 二叉樹的深度,例 [LeetCode]

二叉樹的深度的概念最值得注意的地方,在於 到"葉子"節點的距離。 一般來說,如果直接說“深度”,都是指最大深度,即最遠葉子的距離。 這里放兩道例題,最小深度和最大深度。 1. 二叉樹的最小深度 Given a binary tree, find its minimum depth. ...

Sun Aug 03 06:28:00 CST 2014 0 7446
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM