Oracle Interview Question

Leet code hard problem of tree