LinkedIn interview question

Most difficult was the incomplete code which I have to complete.