920. Number of Music Playlists Hard

@problem@discussion
#Math#Dynamic Programming#Combinatorics



1/**
2 * [920] Number of Music Playlists
3 *
4 * Your music player contains n different songs. You want to listen to goal songs (not necessarily different) during your trip. To avoid boredom, you will create a playlist so that:
5 * 
6 * 	Every song is played at least once.
7 * 	A song can only be played again only if k other songs have been played.
8 * 
9 * Given n, goal, and k, return the number of possible playlists that you can create. Since the answer can be very large, return it modulo 10^9 + 7.
10 *  
11 * Example 1:
12 * 
13 * Input: n = 3, goal = 3, k = 1
14 * Output: 6
15 * Explanation: There are 6 possible playlists: [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], and [3, 2, 1].
16 * 
17 * Example 2:
18 * 
19 * Input: n = 2, goal = 3, k = 0
20 * Output: 6
21 * Explanation: There are 6 possible playlists: [1, 1, 2], [1, 2, 1], [2, 1, 1], [2, 2, 1], [2, 1, 2], and [1, 2, 2].
22 * 
23 * Example 3:
24 * 
25 * Input: n = 2, goal = 3, k = 1
26 * Output: 2
27 * Explanation: There are 2 possible playlists: [1, 2, 1] and [2, 1, 2].
28 * 
29 *  
30 * Constraints:
31 * 
32 * 	0 <= k < n <= goal <= 100
33 * 
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/number-of-music-playlists/
38// discuss: https://leetcode.com/problems/number-of-music-playlists/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43    pub fn num_music_playlists(n: i32, goal: i32, k: i32) -> i32 {
44        0
45    }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52    use super::*;
53
54    #[test]
55    fn test_920() {
56    }
57}
58


Back
© 2025 bowen.ge All Rights Reserved.