Amount of Time for Binary Tree to Be Infected
Medium · Trees · about 20 minutes
Asked at Amazon, Microsoft, Salesforce, Google.
The values of a binary tree are unique. At minute 0 an infection starts at the node with value start. Each minute, every infected node infects its uninfected neighbors (parent and children). Return the number of minutes until the whole tree is infected.