Skip to content

Commit 0f3a858

Browse files
committed
Added README.md file for Diameter of Binary Tree
1 parent 0541a61 commit 0f3a858

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

543-diameter-of-binary-tree/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<h2><a href="https://leetcode.com/problems/diameter-of-binary-tree">Diameter of Binary Tree</a></h2> <img src='https://img.shields.io/badge/Difficulty-Easy-brightgreen' alt='Difficulty: Easy' /><hr><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 class="example">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>
11+
<strong>Input:</strong> root = [1,2,3,4,5]
12+
<strong>Output:</strong> 3
13+
<strong>Explanation:</strong> 3 is the length of the path [4,2,1,3] or [5,2,1,3].
14+
</pre>
15+
16+
<p><strong class="example">Example 2:</strong></p>
17+
18+
<pre>
19+
<strong>Input:</strong> root = [1,2]
20+
<strong>Output:</strong> 1
21+
</pre>
22+
23+
<p>&nbsp;</p>
24+
<p><strong>Constraints:</strong></p>
25+
26+
<ul>
27+
<li>The number of nodes in the tree is in the range <code>[1, 10<sup>4</sup>]</code>.</li>
28+
<li><code>-100 &lt;= Node.val &lt;= 100</code></li>
29+
</ul>

0 commit comments

Comments
 (0)