Skip to content

Commit 1f0b308

Browse files
authored
Create 1181 Diameter of Binary Tree.java
1 parent dfe084d commit 1f0b308

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* Lintcode 1181 · Diameter of Binary Tree && 543. Diameter of Binary Tree
2+
3+
Description
4+
Given a binary tree, you need to compute the length of the diameter of the tree.
5+
The diameter of a binary tree is the length of the longest path between any two nodes in a tree.
6+
7+
Example 1:
8+
Given a binary tree
9+
1
10+
/ \
11+
2 3
12+
/ \
13+
4 5
14+
Return 3, which is the length of the path [4,2,1,3] or [5,2,1,3].
15+
16+
Example 2:
17+
Input:[2,3,#,1]
18+
Output:2
19+
Explanation:
20+
2
21+
/
22+
3
23+
/
24+
1
25+
26+
Constraints:
27+
The number of nodes in the tree is in the range [1, 104].
28+
-100 <= Node.val <= 100
29+
*/
30+

0 commit comments

Comments
 (0)