A playlist is considered a repeating playlist if any of the songs contain a reference to a previous song in the playlist. Otherwise, the playlist will end with the last song which points to undefined.
Implement the method isRepeatingPlaylist that, efficiently with respect to time used, returns true if a playlist is repeating or false if it is not.
For example, the following code prints "true" as both songs point to each other.
let first = new Song("Hello"); let second = new Song("Eye of the tiger"); first.nextSong = second; second.nextSong = first; console.log(first.isRepeatingPlaylist());
- Example case: Wrong answer
- If playlist repeats, last song is followed by first song: Wrong answer
- If playlist repeats, starting songs can be skipped: Wrong answer
- Performance test on a large playlist: Wrong answer