1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/有多少小于当前数字的数字 [how-many-numbers-are-smaller-than-the-current-number].html
2022-03-29 12:43:11 +08:00

41 lines
1.3 KiB
HTML
Raw 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>给你一个数组&nbsp;<code>nums</code>,对于其中每个元素&nbsp;<code>nums[i]</code>,请你统计数组中比它小的所有数字的数目。</p>
<p>换而言之,对于每个&nbsp;<code>nums[i]</code>&nbsp;你必须计算出有效的&nbsp;<code>j</code>&nbsp;的数量,其中 <code>j</code> 满足&nbsp;<code>j != i</code> <strong></strong> <code>nums[j] &lt; nums[i]</code>&nbsp;</p>
<p>以数组形式返回答案。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>nums = [8,1,2,2,3]
<strong>输出:</strong>[4,0,1,1,3]
<strong>解释:</strong>
对于 nums[0]=8 存在四个比它小的数字122 和 3
对于 nums[1]=1 不存在比它小的数字。
对于 nums[2]=2 存在一个比它小的数字1
对于 nums[3]=2 存在一个比它小的数字1
对于 nums[4]=3 存在三个比它小的数字12 和 2
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>nums = [6,5,4,8]
<strong>输出:</strong>[2,1,0,3]
</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输入:</strong>nums = [7,7,7,7]
<strong>输出:</strong>[0,0,0,0]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= nums.length &lt;= 500</code></li>
<li><code>0 &lt;= nums[i] &lt;= 100</code></li>
</ul>