Skip to content

Commit 9997902

Browse files
committed
Create README - LeetHub
1 parent 6a55de2 commit 9997902

File tree

1 file changed

+42
-0
lines changed
  • 2385-amount-of-time-for-binary-tree-to-be-infected

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<h2><a href="https://leetcode.com/problems/amount-of-time-for-binary-tree-to-be-infected/">2385. Amount of Time for Binary Tree to Be Infected</a></h2><h3>Medium</h3><hr><div><p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
2+
3+
<p>Each minute, a node becomes infected if:</p>
4+
5+
<ul>
6+
<li>The node is currently uninfected.</li>
7+
<li>The node is adjacent to an infected node.</li>
8+
</ul>
9+
10+
<p>Return <em>the number of minutes needed for the entire tree to be infected.</em></p>
11+
12+
<p>&nbsp;</p>
13+
<p><strong class="example">Example 1:</strong></p>
14+
<img alt="" src="https://assets.leetcode.com/uploads/2022/06/25/image-20220625231744-1.png" style="width: 400px; height: 306px;">
15+
<pre><strong>Input:</strong> root = [1,5,3,null,4,10,6,9,2], start = 3
16+
<strong>Output:</strong> 4
17+
<strong>Explanation:</strong> The following nodes are infected during:
18+
- Minute 0: Node 3
19+
- Minute 1: Nodes 1, 10 and 6
20+
- Minute 2: Node 5
21+
- Minute 3: Node 4
22+
- Minute 4: Nodes 9 and 2
23+
It takes 4 minutes for the whole tree to be infected so we return 4.
24+
</pre>
25+
26+
<p><strong class="example">Example 2:</strong></p>
27+
<img alt="" src="https://assets.leetcode.com/uploads/2022/06/25/image-20220625231812-2.png" style="width: 75px; height: 66px;">
28+
<pre><strong>Input:</strong> root = [1], start = 1
29+
<strong>Output:</strong> 0
30+
<strong>Explanation:</strong> At minute 0, the only node in the tree is infected so we return 0.
31+
</pre>
32+
33+
<p>&nbsp;</p>
34+
<p><strong>Constraints:</strong></p>
35+
36+
<ul>
37+
<li>The number of nodes in the tree is in the range <code>[1, 10<sup>5</sup>]</code>.</li>
38+
<li><code>1 &lt;= Node.val &lt;= 10<sup>5</sup></code></li>
39+
<li>Each node has a <strong>unique</strong> value.</li>
40+
<li>A node with a value of <code>start</code> exists in the tree.</li>
41+
</ul>
42+
</div>

0 commit comments

Comments
 (0)