Spotify interview question

Algo question round linkedlist