mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
20 lines
730 B
HTML
20 lines
730 B
HTML
<p>Given an integer array <code>nums</code>, return <em>the number of <strong>reverse pairs</strong> in the array</em>.</p>
|
|
|
|
<p>A reverse pair is a pair <code>(i, j)</code> where <code>0 <= i < j < nums.length</code> and <code>nums[i] > 2 * nums[j]</code>.</p>
|
|
|
|
<p> </p>
|
|
<p><strong>Example 1:</strong></p>
|
|
<pre><strong>Input:</strong> nums = [1,3,2,3,1]
|
|
<strong>Output:</strong> 2
|
|
</pre><p><strong>Example 2:</strong></p>
|
|
<pre><strong>Input:</strong> nums = [2,4,3,5,1]
|
|
<strong>Output:</strong> 3
|
|
</pre>
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= nums.length <= 5 * 10<sup>4</sup></code></li>
|
|
<li><code>-2<sup>31</sup> <= nums[i] <= 2<sup>31</sup> - 1</code></li>
|
|
</ul>
|