Skip to content

Commit 928bf16

Browse files
committed
Create README - LeetHub
1 parent e24d075 commit 928bf16

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<h2>1325. Delete Leaves With a Given Value</h2><h3>Medium</h3><hr><div><p>Given a binary tree&nbsp;<code>root</code>&nbsp;and an integer&nbsp;<code>target</code>, delete all the&nbsp;<strong>leaf nodes</strong>&nbsp;with value <code>target</code>.</p>
2+
3+
<p>Note&nbsp;that once you delete a leaf node with value <code>target</code><strong>,&nbsp;</strong>if it's parent node becomes a leaf node and has the value <code><font face="monospace">target</font></code>, it should also be deleted (you need to continue doing that until you can't).</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong>Example 1:</strong></p>
7+
8+
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/01/09/sample_1_1684.png" style="width: 550px; height: 120px;"></strong></p>
9+
10+
<pre><strong>Input:</strong> root = [1,2,3,2,null,2,4], target = 2
11+
<strong>Output:</strong> [1,null,3,null,4]
12+
<strong>Explanation:</strong> Leaf nodes in green with value (target = 2) are removed (Picture in left).
13+
After removing, new nodes become leaf nodes with value (target = 2) (Picture in center).
14+
</pre>
15+
16+
<p><strong>Example 2:</strong></p>
17+
18+
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/01/09/sample_2_1684.png" style="width: 300px; height: 120px;"></strong></p>
19+
20+
<pre><strong>Input:</strong> root = [1,3,3,3,2], target = 3
21+
<strong>Output:</strong> [1,3,null,null,2]
22+
</pre>
23+
24+
<p><strong>Example 3:</strong></p>
25+
26+
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/01/15/sample_3_1684.png" style="width: 420px; height: 150px;"></strong></p>
27+
28+
<pre><strong>Input:</strong> root = [1,2,null,2,null,2], target = 2
29+
<strong>Output:</strong> [1]
30+
<strong>Explanation:</strong> Leaf nodes in green with value (target = 2) are removed at each step.
31+
</pre>
32+
33+
<p><strong>Example 4:</strong></p>
34+
35+
<pre><strong>Input:</strong> root = [1,1,1], target = 1
36+
<strong>Output:</strong> []
37+
</pre>
38+
39+
<p><strong>Example 5:</strong></p>
40+
41+
<pre><strong>Input:</strong> root = [1,2,3], target = 1
42+
<strong>Output:</strong> [1,2,3]
43+
</pre>
44+
45+
<p>&nbsp;</p>
46+
<p><strong>Constraints:</strong></p>
47+
48+
<ul>
49+
<li><code>1 &lt;= target&nbsp;&lt;= 1000</code></li>
50+
<li>The&nbsp;given binary tree will have between&nbsp;<code>1</code>&nbsp;and&nbsp;<code>3000</code>&nbsp;nodes.</li>
51+
<li>Each node's value is between <code>[1, 1000]</code>.</li>
52+
</ul>
53+
</div>

0 commit comments

Comments
 (0)