You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: solution/0600-0699/0629.K Inverse Pairs Array/README_EN.md
+58-24
Original file line number
Diff line number
Diff line change
@@ -6,20 +6,12 @@
6
6
7
7
<p>Given two integers <code>n</code> and <code>k</code>, find how many different arrays consist of numbers from <code>1</code> to <code>n</code> such that there are exactly <code>k</code> inverse pairs.</p>
8
8
9
-
10
-
11
9
<p>We define an inverse pair as following: For <code>i<sub>th</sub></code> and <code>j<sub>th</sub></code> element in the array, if <code>i</code> < <code>j</code> and <code>a[i]</code> > <code>a[j]</code> then it's an inverse pair; Otherwise, it's not.</p>
12
10
13
-
14
-
15
11
<p>Since the answer may be very large, the answer should be modulo 10<sup>9</sup> + 7.</p>
16
12
17
-
18
-
19
13
<p><b>Example 1:</b></p>
20
14
21
-
22
-
23
15
<pre>
24
16
25
17
<b>Input:</b> n = 3, k = 0
@@ -32,16 +24,10 @@ Only the array [1,2,3] which consists of numbers from 1 to 3 has exactly 0 inver
32
24
33
25
</pre>
34
26
35
-
36
-
37
27
<p> </p>
38
28
39
-
40
-
41
29
<p><b>Example 2:</b></p>
42
30
43
-
44
-
45
31
<pre>
46
32
47
33
<b>Input:</b> n = 3, k = 1
@@ -54,26 +40,16 @@ The array [1,3,2] and [2,1,3] have exactly 1 inverse pair.
54
40
55
41
</pre>
56
42
57
-
58
-
59
43
<p> </p>
60
44
61
-
62
-
63
45
<p><b>Note:</b></p>
64
46
65
-
66
-
67
47
<ol>
68
48
<li>The integer <code>n</code> is in the range [1, 1000] and <code>k</code> is in the range [0, 1000].</li>
0 commit comments