Zillow interview question

Standard coding questions on DP and trees