As reported: Amazon SDE-2 (L5, Bangalore, July 2025), round 1 — 60 minutes of DSA and Leadership Principles: Amount of Time for Binary Tree to Be Infected, then Remove K Digits.
You are given the root of a binary tree with unique values and an integer start. At minute 0 the node with value start is infected. Each minute, an uninfected node adjacent to an infected node (its parent or a child) becomes infected. Return the number of minutes until the whole tree is infected.
This is LeetCode 2385 — Amount of Time for Binary Tree to Be Infected.
Example 1
root = [1,5,3,null,4,10,6,9,2], start = 3
Output: 4
Example 2
root = [1], start = 1
Output: 0
Constraints: 1 ≤ number of nodes ≤ 10⁵; 1 ≤ Node.val ≤ 10⁵; values are unique; a node with value start exists.
Code runner format: two lines: root in LeetCode's level-order format, then start. Implement amountOfTime(root, start); the harness prints the result.