Microsoft interview question

Binary Tree problem. Medium difficulty