Microsoft Interview Question

A DSA question based on trees