Spotify: All combinations of song durations that fill an exact playlist length
Problem. You get a list of song durations and a target playlist length. Return every combination of songs whose durations add up exactly to the target.
Example (illustrative). Durations [2, 3, 5] and target 5 give [2, 3] and [5].
Things to clarify with the interviewer (the post gives no constraints):
- Can a song be used more than once?
- Can the list contain duplicate durations, and should duplicate combinations be removed?
- Does the order of songs within a combination matter?
Your choice of backtracking with pruning depends on these answers.
Context. This was asked in an internship loop that also had a basic system design round. The candidate received an offer and later declined it. The post does not describe any follow-ups or what the interviewer focused on.
Comments 0
No comments yet. Ask the author something, or add what happened in your own round.