You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: solution/0800-0899/0865.Smallest Subtree with all the Deepest Nodes/README_EN.md
+125-23
Original file line number
Diff line number
Diff line change
@@ -6,24 +6,14 @@
6
6
7
7
<p>Given the <code>root</code> of a binary tree, the depth of each node is <strong>the shortest distance to the root</strong>.</p>
8
8
9
-
10
-
11
9
<p>Return <em>the smallest subtree</em> such that it contains <strong>all the deepest nodes</strong> in the original tree.</p>
12
10
13
-
14
-
15
11
<p>A node is called <strong>the deepest</strong> if it has the largest depth possible among any node in the entire tree.</p>
16
12
17
-
18
-
19
13
<p>The <strong>subtree</strong> of a node is tree consisting of that node, plus the set of all descendants of that node.</p>
20
14
21
-
22
-
23
15
<p><strong>Note:</strong> This question is the same as 1123: <ahref="https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/"target="_blank">https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/</a></p>
24
16
25
-
26
-
27
17
<p> </p>
28
18
29
19
<p><strong>Example 1:</strong></p>
@@ -44,12 +34,8 @@ Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is
44
34
45
35
</pre>
46
36
47
-
48
-
49
37
<p><strong>Example 2:</strong></p>
50
38
51
-
52
-
53
39
<pre>
54
40
55
41
<strong>Input:</strong> root = [1]
@@ -60,12 +46,8 @@ Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is
60
46
61
47
</pre>
62
48
63
-
64
-
65
49
<p><strong>Example 3:</strong></p>
66
50
67
-
68
-
69
51
<pre>
70
52
71
53
<strong>Input:</strong> root = [0,1,3,null,2]
@@ -76,14 +58,10 @@ Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is
76
58
77
59
</pre>
78
60
79
-
80
-
81
61
<p> </p>
82
62
83
63
<p><strong>Constraints:</strong></p>
84
64
85
-
86
-
87
65
<ul>
88
66
<li>The number of nodes in the tree will be in the range <code>[1, 500]</code>.</li>
89
67
<li><code>0 <= Node.val <= 500</code></li>
@@ -97,13 +75,137 @@ Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is
0 commit comments