Google interview question

Trees based on meduim problem