I was asked:
I did this but follow up was like, what if tree contains duplicates? I gave brute force.
Is there any optimal soution to handle duplicates?