## Amount of Time for Binary Tree to Be Infected solution leetcode

You are given the `root`

of a binary tree with **unique** values, and an integer `start`

. At minute `0`

, an **infection** starts from the node with value `start`

.

Each minute, a node becomes infected if:

- The node is currently uninfected.
- The node is adjacent to an infected node.

Return *the number of minutes needed for the entire tree to be infected.*

You can fill out the contact information at the registration step. LeetCode may reach out to eligible contest winners for an interview opportunity with LeetCode.

**⭐ Bonus Prizes⭐**

- Contestants ranked
**1st**will win a Apple HomePod mini - Contestants ranked
**2nd**will win a Logitech G903 LIGHTSPEED Gaming Mouse - Contestants ranked
**3rd ~ 5th**will win a LeetCode Backpack - Contestants ranked
**6th ~ 10th**will win a LeetCode water bottle - Contestants ranked
**11th ~ 20th**will win a LeetCode Big O Notebook

Only LCUS(leetcode.com) accounts are eligible for the bonus rewards. After the ranking is finalized, a LeetCode team member will reach out to you through email regarding the gift!

## Amount of Time for Binary Tree to Be Infected solution leetcode

**Example 1:**

Input:root = [1,5,3,null,4,10,6,9,2], start = 3Output:4Explanation:The following nodes are infected during: - Minute 0: Node 3 - Minute 1: Nodes 1, 10 and 6 - Minute 2: Node 5 - Minute 3: Node 4 - Minute 4: Nodes 9 and 2 It takes 4 minutes for the whole tree to be infected so we return 4.

**Example 2:**

Input:root = [1], start = 1Output:0Explanation:At minute 0, the only node in the tree is infected so we return 0.

## Amount of Time for Binary Tree to Be Infected solution leetcode

**Constraints:**

- The number of nodes in the tree is in the range
`[1, 10`

.^{5}] `1 <= Node.val <= 10`

^{5}- Each node has a
**unique**value. - A node with a value of
`start`

exists in the tree.