Skip to content

Practice K Inverse Pairs Array

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#629
LeetCode Problem

K Inverse Pairs Array

Problem Statement

An inverse pair consists of indices i < j with nums[i] greater than nums[j]. Count the permutations of integers 1 through n that have exactly k inverse pairs, and return the count modulo 10^9 + 7.

Source: K Inverse Pairs Array on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 3, k = 0
Output
1

# Example 2

Input
n = 3, k = 1
Output
2

Constraints

1 <= n <= 1000
0 <= k <= 1000

Related LeetCode Problems

Practice more problems similar to K Inverse Pairs Array.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.