Meta interview question

Leetcode tree based medium coding question