<div><p>Given an undirected tree, return its diameter: the number of <strong>edges</strong> in a longest path in that tree.</p>
<p>The tree is given as an array of <code>edges</code> where <code>edges[i] = [u, v]</code> is a bidirectional edge between nodes <code>u</code> and <code>v</code>. Each node has labels in the set <code>{0, 1, ..., edges.length}</code>.</p>
<p> </p>
<p><strong>Example 1:</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2019/06/14/1397_example_1.PNG" style="width: 226px; height: 233px;"></p>
<pre><strong>Input:</strong> edges = [[0,1],[0,2]]
<strong>Output:</strong> 2
<strong>Explanation: </strong>
A longest path of the tree is the path 1 - 0 - 2.
</pre>
<p><strong>Example 2:</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2019/06/14/1397_example_2.PNG" style="width: 350px; height: 316px;"></p>
<pre><strong>Input:</strong> edges = [[0,1],[1,2],[2,3],[1,4],[4,5]]
<strong>Output:</strong> 4
<strong>Explanation: </strong>
A longest path of the tree is the path 3 - 2 - 1 - 4 - 5.
</pre>
<p> </p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>0 <= edges.length < 10^4</code></li>
<li><code>edges[i][0] != edges[i][1]</code></li>
<li><code>0 <= edges[i][j] <= edges.length</code></li>
<li>The given edges form an undirected tree.</li>
</ul>
</div>