Number of Music Playlists
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You own n distinct songs and want a playlist of exactly goal tracks (songs may repeat). The playlist must satisfy both rules:
- every one of the n songs appears at least once, and
- a song may be played again only after at least k **other** songs have been played since its previous play.
Return the number of different playlists (ordered track sequences) modulo 10^9 + 7.
Examples
Constraints
- 0 <= k < n <= goal <= 100
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.