A building's air ducts connect its rooms like a binary tree: each room is joined to the room above it and to up to two rooms below. A fire starts in one room. Every minute, smoke spreads from each smoky room to every room it is directly joined to, up or down.
Each room is a node { val, left, right }, where val is an integer and left and right are nodes or null. Every val in the tree is different.
minutesToFill(root, start) returns how many minutes pass until every room has smoke, when the fire starts in the room whose val is start. A tree with one room returns 0.
smokeTimeline(root, start) returns an array whose entry m lists the values of the rooms that first get smoke at minute m, sorted ascending. Entry 0 is [start].
Rules:
If root is null, or no room has the value start, throw a RangeError.
Trees can have 200,000 rooms and be 100,000 levels deep. Recursing that deep overflows the call stack, and re-scanning the whole tree every minute is quadratic, so neither will finish.