Your music player contains?N
?different songs and she wants to listen to?L
?(not necessarily different) songs during your trip. ?You?create?a playlist so?that:
K
?other songs have been playedReturn the number of possible playlists.??As the answer can be very large, return it modulo?10^9 + 7
.
Example 1:
Input: N = 3, L = 3, K = 1
Output: 6
Explanation: There are 6 possible playlists. [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1].
Example 2:
Input: N = 2, L = 3, K = 0
Output: 6 Explanation: There are 6 possible playlists. [1, 1, 2], [1, 2, 1], [2, 1, 1], [2, 2, 1], [2, 1, 2], [1, 2, 2]
Example 3:
Input: N = 2, L = 3, K = 1
Output: 2
Explanation: There are 2 possible playlists. [1, 2, 1], [2, 1, 2]
Note:
0 <= K < N <= L <= 100
Github 同步地址:
https://github.com/grandyang/leetcode/issues/920
参考资料:
https://leetcode.com/problems/number-of-music-playlists/
LeetCode All in One 题目讲解汇总(持续更新中...)
[LeetCode] 920. Number of Music Playlists 音乐播放列表的个数
原文:https://www.cnblogs.com/grandyang/p/11741490.html