Class Solution
java.lang.Object
g0901_1000.s0920_number_of_music_playlists.Solution
920 - Number of Music Playlists.<p>Hard</p>
<p>Your music player contains <code>n</code> different songs. You want to listen to <code>goal</code> songs (not necessarily different) during your trip. To avoid boredom, you will create a playlist so that:</p>
<ul>
<li>Every song is played <strong>at least once</strong>.</li>
<li>A song can only be played again only if <code>k</code> other songs have been played.</li>
</ul>
<p>Given <code>n</code>, <code>goal</code>, and <code>k</code>, return <em>the number of possible playlists that you can create</em>. Since the answer can be very large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> n = 3, goal = 3, k = 1</p>
<p><strong>Output:</strong> 6</p>
<p><strong>Explanation:</strong> There are 6 possible playlists: [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], and [3, 2, 1].</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> n = 2, goal = 3, k = 0</p>
<p><strong>Output:</strong> 6</p>
<p><strong>Explanation:</strong> There are 6 possible playlists: [1, 1, 2], [1, 2, 1], [2, 1, 1], [2, 2, 1], [2, 1, 2], and [1, 2, 2].</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> n = 2, goal = 3, k = 1</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> There are 2 possible playlists: [1, 2, 1] and [2, 1, 2].</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>0 <= k < n <= goal <= 100</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
numMusicPlaylists
public int numMusicPlaylists(int n, int l, int k)
-