Content Playlist Combinations
Sharechat users love creating engaging video playlists. To help users discover new content, we're building a feature that suggests sequences of video topics that sum up to a specific duration. This problem challenges you to find all such valid topic sequences.
Implement a function findPlaylistCombinations that takes a list of available video clips (each described by its topic and duration) and a targetDuration. The function should return all unique sequences of clip topics whose total duration exactly matches targetDuration.
clips: An array of objects, where each object has two properties: topic (string) and duration (number).targetDuration: A number representing the exact total duration the playlist must have.string[][] (array of arrays of strings), where each inner array represents a valid sequence of clip topics. The order of topics within a sequence matters. The order of sequences in the output array does not matter.duration values will be positive integers.Examples
Example 1
Input:
clips = [{"topic":"comedy","duration":10},{"topic":"drama","duration":15}], targetDuration = 25
Output:
[["comedy","drama"],["drama","comedy"]]
Note:
"comedy" (10) + "drama" (15) = 25. "drama" (15) + "comedy" (10) = 25. These are two distinct sequences.
Example 2
Input:
clips = [{"topic":"short","duration":5},{"topic":"medium","duration":10}], targetDuration = 15
Output:
[["short","short","short"],["short","medium"],["medium","short"]]
Note:
Example 3
Input:
clips = [{"topic":"news","duration":20}], targetDuration = 10
Output:
[]
Note:
No combination of "news" clips can sum up to 10.
Constraints
1 <= clips.length <= 151 <= topic.length <= 101 <= duration <= 1001 <= targetDuration <= 500clips array.clips array will not be empty.Loading editor...