Intuit interview question

1 medium LC question on trees