1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-11 18:31:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/交易逆序对的总数 [shu-zu-zhong-de-ni-xu-dui-lcof].html
2025-01-09 20:29:41 +08:00

18 lines
638 B
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>在股票交易中,如果前一天的股价高于后一天的股价,则可以认为存在一个「交易逆序对」。请设计一个程序,输入一段时间内的股票交易记录 <code>record</code>,返回其中存在的「交易逆序对」总数。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>record = [9, 7, 5, 4, 6]
<strong>输出:</strong>8
<strong>解释:</strong>交易中的逆序对为 (9, 7), (9, 5), (9, 4), (9, 6), (7, 5), (7, 4), (7, 6), (5, 4)。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<p><code>0 &lt;= record.length &lt;= 50000</code></p>