LinkedIn Interview Question

fairly challenging tree question