mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
存量题库数据更新
This commit is contained in:
@@ -1,15 +1,34 @@
|
||||
<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>A <strong>reverse pair</strong> is a pair <code>(i, j)</code> where:</p>
|
||||
|
||||
<ul>
|
||||
<li><code>0 <= i < j < nums.length</code> and</li>
|
||||
<li><code>nums[i] > 2 * nums[j]</code>.</li>
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<pre><strong>Input:</strong> nums = [1,3,2,3,1]
|
||||
<p><strong class="example">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
|
||||
<strong>Explanation:</strong> The reverse pairs are:
|
||||
(1, 4) --> nums[1] = 3, nums[4] = 1, 3 > 2 * 1
|
||||
(3, 4) --> nums[3] = 3, nums[4] = 1, 3 > 2 * 1
|
||||
</pre>
|
||||
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [2,4,3,5,1]
|
||||
<strong>Output:</strong> 3
|
||||
<strong>Explanation:</strong> The reverse pairs are:
|
||||
(1, 4) --> nums[1] = 4, nums[4] = 1, 4 > 2 * 1
|
||||
(2, 4) --> nums[2] = 3, nums[4] = 1, 3 > 2 * 1
|
||||
(3, 4) --> nums[3] = 5, nums[4] = 1, 5 > 2 * 1
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
|
Reference in New Issue
Block a user