Microsoft interview question

A DSA question based on trees