Skip to content

Commit 33617ef

Browse files
committed
Create README - LeetHub
1 parent 071e07d commit 33617ef

File tree

1 file changed

+30
-0
lines changed
  • 0893-all-nodes-distance-k-in-binary-tree

1 file changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<h2><a href="https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree">893. All Nodes Distance K in Binary Tree</a></h2><h3>Medium</h3><hr><p>Given the <code>root</code> of a binary tree, the value of a target node <code>target</code>, and an integer <code>k</code>, return <em>an array of the values of all nodes that have a distance </em><code>k</code><em> from the target node.</em></p>
2+
3+
<p>You can return the answer in <strong>any order</strong>.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
<img alt="" src="https://s3-lc-upload.s3.amazonaws.com/uploads/2018/06/28/sketch0.png" style="width: 500px; height: 429px;" />
8+
<pre>
9+
<strong>Input:</strong> root = [3,5,1,6,2,0,8,null,null,7,4], target = 5, k = 2
10+
<strong>Output:</strong> [7,4,1]
11+
Explanation: The nodes that are a distance 2 from the target node (with value 5) have values 7, 4, and 1.
12+
</pre>
13+
14+
<p><strong class="example">Example 2:</strong></p>
15+
16+
<pre>
17+
<strong>Input:</strong> root = [1], target = 1, k = 3
18+
<strong>Output:</strong> []
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, 500]</code>.</li>
26+
<li><code>0 &lt;= Node.val &lt;= 500</code></li>
27+
<li>All the values <code>Node.val</code> are <strong>unique</strong>.</li>
28+
<li><code>target</code> is the value of one of the nodes in the tree.</li>
29+
<li><code>0 &lt;= k &lt;= 1000</code></li>
30+
</ul>

0 commit comments

Comments
 (0)