Google Interview Question

A LC hard tree question.