Oracle interview question

Leet code hard problem of tree