Meituan interview question

A complex binary tree question.