Finoit interview question

In second round the two questions were based on binary tree. Pretty complex.