Harver interview question

an algorithm problem with node