629. K Inverse Pairs Array
2017-09-07 23:02
471 查看
Given two integers
find how many different arrays consist of numbers from
that there are exactly
We define an inverse pair as following: For
in the array, if
it's an inverse pair; Otherwise, it's not.
Since the answer may be very large, the answer should be modulo 109 + 7.
Example 1:
Example 2:
Note:
The integer
in the range [0, 1000].
nand
k,
find how many different arrays consist of numbers from
1to
nsuch
that there are exactly
kinverse pairs.
We define an inverse pair as following: For
ithand
jthelement
in the array, if
i<
jand
a[i]>
a[j]then
it's an inverse pair; Otherwise, it's not.
Since the answer may be very large, the answer should be modulo 109 + 7.
Example 1:
Input: n = 3, k = 0 Output: 1 Explanation: Only the array [1,2,3] which consists of numbers from 1 to 3 has exactly 0 inverse pair.
Example 2:
Input: n = 3, k = 1 Output: 2 Explanation: The array [1,3,2] and [2,1,3] have exactly 1 inverse pair.
Note:
The integer
nis in the range [1, 1000] and
kis
in the range [0, 1000].
相关文章推荐
- 629. K Inverse Pairs Array 自制答案
- 629. K Inverse Pairs Array
- [Leetcode] 629. K Inverse Pairs Array 解题报告
- [leetcode]629. K Inverse Pairs Array
- leetcode 629. K Inverse Pairs Array
- leetcode:K inverse pairs array
- K Inverse Pairs Array (leetcode)
- [LeetCode] K Inverse Pairs Array K个翻转对数组
- Leetcode | K Inverse Pairs Array
- 629. K Inverse Pairs Array
- K Inverse Pairs Array
- 629. K Inverse Pairs Array
- K Inverse Pairs Array - LeetCode
- leetcode--532.K-DiffPairsInAnArray
- Array-K-diff Pairs in an Array
- Leetcode 532. K-diff Pairs in an Array(Easy)
- K-diff Pairs in an Array
- [LeetCode]532. K-diff Pairs in an Array
- LeetCode - 532. K-diff Pairs in an Array
- 【Leetcode】532. K-diff Pairs in an Array