Google interview question

A LC hard tree question.