Google interview question

Asked to solve a complex algorithm