Skip to content

Commit 8b2b751

Browse files
Create README - LeetHub
1 parent 52f4f65 commit 8b2b751

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

diameter-of-binary-tree/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<h2>543. Diameter of Binary Tree</h2><h3>Easy</h3><hr><div><p>Given the <code>root</code> of a binary tree, return <em>the length of the <strong>diameter</strong> of the tree</em>.</p>
2+
3+
<p>The <strong>diameter</strong> of a binary tree is the <strong>length</strong> of the longest path between any two nodes in a tree. This path may or may not pass through the <code>root</code>.</p>
4+
5+
<p>The <strong>length</strong> of a path between two nodes is represented by the number of edges between them.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong>Example 1:</strong></p>
9+
<img alt="" src="https://assets.leetcode.com/uploads/2021/03/06/diamtree.jpg" style="width: 292px; height: 302px;">
10+
<pre><strong>Input:</strong> root = [1,2,3,4,5]
11+
<strong>Output:</strong> 3
12+
<strong>Explanation:</strong> 3 is the length of the path [4,2,1,3] or [5,2,1,3].
13+
</pre>
14+
15+
<p><strong>Example 2:</strong></p>
16+
17+
<pre><strong>Input:</strong> root = [1,2]
18+
<strong>Output:</strong> 1
19+
</pre>
20+
21+
<p>&nbsp;</p>
22+
<p><strong>Constraints:</strong></p>
23+
24+
<ul>
25+
<li>The number of nodes in the tree is in the range <code>[1, 10<sup>4</sup>]</code>.</li>
26+
<li><code>-100 &lt;= Node.val &lt;= 100</code></li>
27+
</ul>
28+
</div>

0 commit comments

Comments
 (0)