Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ tags:
<p><strong>示例 1:</strong></p>

<pre>
<strong>输入:</strong>nums = [<code>4,5,6,7,0,1,2]</code>, target = 0
<strong>输入:</strong>nums = [4,5,6,7,0,1,2], target = 0
<strong>输出:</strong>4
</pre>

<p><strong>示例&nbsp;2:</strong></p>

<pre>
<strong>输入:</strong>nums = [<code>4,5,6,7,0,1,2]</code>, target = 3
<strong>输入:</strong>nums = [4,5,6,7,0,1,2], target = 3
<strong>输出:</strong>-1</pre>

<p><strong>示例 3:</strong></p>
Expand Down
1 change: 1 addition & 0 deletions solution/0100-0199/0169.Majority Element/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ tags:
<li><code>n == nums.length</code></li>
<li><code>1 &lt;= n &lt;= 5 * 10<sup>4</sup></code></li>
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
<li>输入保证数组中一定有一个多数元素。</li>
</ul>

<p>&nbsp;</p>
Expand Down
1 change: 1 addition & 0 deletions solution/0100-0199/0169.Majority Element/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ tags:
<li><code>n == nums.length</code></li>
<li><code>1 &lt;= n &lt;= 5 * 10<sup>4</sup></code></li>
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
<li>The input is generated such that a majority element will exist in the array.</li>
</ul>

<p>&nbsp;</p>
Expand Down
4 changes: 2 additions & 2 deletions solution/0200-0299/0224.Basic Calculator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ tags:
<li><code>1 &lt;= s.length &lt;= 3&nbsp;* 10<sup>5</sup></code></li>
<li><code>s</code> 由数字、<code>'+'</code>、<code>'-'</code>、<code>'('</code>、<code>')'</code>、和 <code>' '</code> 组成</li>
<li><code>s</code> 表示一个有效的表达式</li>
<li><font color="#c7254e"><font face="Menlo, Monaco, Consolas, Courier New, monospace"><span style="font-size:12.6px"><span style="background-color:#f9f2f4">'+'</span></span></font></font> 不能用作一元运算(例如, <font color="#c7254e"><font face="Menlo, Monaco, Consolas, Courier New, monospace"><span style="font-size:12.6px"><span style="background-color:#f9f2f4">"+1"</span></span></font></font>&nbsp;和 <code>"+(2 + 3)"</code>&nbsp;无效)</li>
<li><font color="#c7254e"><font face="Menlo, Monaco, Consolas, Courier New, monospace"><span style="font-size:12.6px"><span style="background-color:#f9f2f4">'-'</span></span></font></font> 可以用作一元运算(即 <font color="#c7254e"><font face="Menlo, Monaco, Consolas, Courier New, monospace"><span style="font-size:12.6px"><span style="background-color:#f9f2f4">"-1"</span></span></font></font>&nbsp;和 <code>"-(2 + 3)"</code>&nbsp;是有效的)</li>
<li><code>'+'</code>&nbsp;不能用作一元运算(例如, <code>"+1"</code>&nbsp;和 <code>"+(2 + 3)"</code>&nbsp;无效)</li>
<li><code>'-'</code>&nbsp;可以用作一元运算(即 <code>"-1"</code>&nbsp;和 <code>"-(2 + 3)"</code>&nbsp;是有效的)</li>
<li>输入中不存在两个连续的操作符</li>
<li>每个数字和运行的计算将适合于一个有符号的 32位 整数</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ tags:
<pre>
<strong>输入:</strong>nums = [2,1,5,0,4,6]
<strong>输出:</strong>true
<strong>解释:</strong>其中一个满足题意的三元组是 (3, 4, 5),因为 nums[3] == 0 &lt; nums[4] == 4 &lt; nums[5] == 6
<strong>解释:</strong>其中一个满足题意的三元组是 (1, 4, 5),因为 nums[1] == 1 &lt; nums[4] == 4 &lt; nums[5] == 6
</pre>

<p>&nbsp;</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ tags:
<pre>
<strong>Input:</strong> nums = [2,1,5,0,4,6]
<strong>Output:</strong> true
<strong>Explanation:</strong> One of the valid triplet is (3, 4, 5), because nums[3] == 0 &lt; nums[4] == 4 &lt; nums[5] == 6.
<strong>Explanation:</strong> One of the valid triplet is (1, 4, 5), because nums[1] == 1 &lt; nums[4] == 4 &lt; nums[5] == 6.
</pre>

<p>&nbsp;</p>
Expand Down
25 changes: 11 additions & 14 deletions solution/0300-0399/0352.Data Stream as Disjoint Intervals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,28 @@ tags:

<!-- description:start -->

<p>&nbsp;给你一个由非负整数&nbsp;<code>a<sub>1</sub>, a<sub>2</sub>, ..., a<sub>n</sub></code> 组成的数据流输入,请你将到目前为止看到的数字总结为不相交的区间列表。</p>
<p>给你一个由非负整数组成的数据流输入 <code>a<sub>1</sub>, a<sub>2</sub>, ..., a<sub>n</sub></code>,请你将目前为止看到的数字汇总为一组不相交的区间列表。</p>

<p>实现 <code>SummaryRanges</code> 类:</p>

<div class="original__bRMd">
<div>
<ul>
<li><code>SummaryRanges()</code> 使用一个空数据流初始化对象。</li>
<li><code>void addNum(int val)</code> 向数据流中加入整数 <code>val</code> 。</li>
<li><code>int[][] getIntervals()</code> 以不相交区间&nbsp;<code>[start<sub>i</sub>, end<sub>i</sub>]</code> 的列表形式返回对数据流中整数的总结。</li>
<li><code>SummaryRanges()</code> 初始化一个空的数据流对象。</li>
<li><code>void addNum(int value)</code> 将整数 <code>value</code> 添加到数据流中。</li>
<li><code>int[][] getIntervals()</code> 返回当前数据流中的整数汇总为一组不相交的区间列表 <code>[start<sub>i</sub>, end<sub>i</sub>]</code>。答案应按 <code>start<sub>i</sub></code> 升序排序。</li>
</ul>

<p>&nbsp;</p>

<p><strong>示例:</strong></p>
<p><strong class="example">示例 1:</strong></p>

<pre>
<strong>输入</strong>
<strong>输入</strong>
["SummaryRanges", "addNum", "getIntervals", "addNum", "getIntervals", "addNum", "getIntervals", "addNum", "getIntervals", "addNum", "getIntervals"]
[[], [1], [], [3], [], [7], [], [2], [], [6], []]
<strong>输出</strong>
<strong>输出</strong>
[null, null, [[1, 1]], null, [[1, 1], [3, 3]], null, [[1, 1], [3, 3], [7, 7]], null, [[1, 3], [7, 7]], null, [[1, 3], [6, 7]]]

<strong>解释</strong>
<strong>解释</strong>
SummaryRanges summaryRanges = new SummaryRanges();
summaryRanges.addNum(1); // arr = [1]
summaryRanges.getIntervals(); // 返回 [[1, 1]]
Expand All @@ -63,11 +61,10 @@ summaryRanges.getIntervals(); // 返回 [[1, 3], [6, 7]]
<p><strong>提示:</strong></p>

<ul>
<li><code>0 &lt;= val &lt;= 10<sup>4</sup></code></li>
<li>最多调用&nbsp;<code>addNum</code> 和 <code>getIntervals</code> 方法 <code>3 * 10<sup>4</sup></code> 次</li>
<li><code>0 &lt;= value &lt;= 10<sup>4</sup></code></li>
<li>最多会调用 <code>addNum</code> 和 <code>getIntervals</code> 方法 <code>3 * 10<sup>4</sup></code> 次。</li>
<li>最多会调用 <code>getIntervals</code> 方法 <code>10<sup>2</sup></code> 次。</li>
</ul>
</div>
</div>

<p>&nbsp;</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/0400-0499/0442.Fi
tags:
- 数组
- 哈希表
- 排序
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/0400-0499/0442.Fi
tags:
- Array
- Hash Table
- Sorting
---

<!-- problem:start -->
Expand Down
2 changes: 1 addition & 1 deletion solution/0600-0699/0649.Dota2 Senate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tags:
<p>Dota2 参议院由来自两派的参议员组成。现在参议院希望对一个 Dota2 游戏里的改变作出决定。他们以一个基于轮为过程的投票进行。在每一轮中,每一位参议员都可以行使两项权利中的 <strong>一 </strong>项:</p>

<ul>
<li><strong>禁止一名参议员的权利</strong>:参议员可以让另一位参议员在这一轮和随后的几轮中丧失<strong> 所有的权利 </strong>。</li>
<li><strong>剥夺一名参议员的权利</strong>:一名参议员可以使另一名参议员在本轮及所有后续轮次中失去所有权利。</li>
<li><strong>宣布胜利</strong>:如果参议员发现有权利投票的参议员都是 <strong>同一个阵营的</strong> ,他可以宣布胜利并决定在游戏中的有关变化。</li>
</ul>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ n = 3, edges = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 1
<p><strong>提示:</strong></p>

<ul>
<li><code>1 &lt;= n &lt;= 100</code></li>
<li><code>2 &lt;= n &lt;= 100</code></li>
<li><code>0 &lt;= flights.length &lt;= (n * (n - 1) / 2)</code></li>
<li><code>flights[i].length == 3</code></li>
<li><code>0 &lt;= from<sub>i</sub>, to<sub>i</sub> &lt; n</code></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The optimal path with no stops from city 0 to 2 is marked in red and has cost 50
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= n &lt;= 100</code></li>
<li><code>2 &lt;= n &lt;= 100</code></li>
<li><code>0 &lt;= flights.length &lt;= (n * (n - 1) / 2)</code></li>
<li><code>flights[i].length == 3</code></li>
<li><code>0 &lt;= from<sub>i</sub>, to<sub>i</sub> &lt; n</code></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ activity_type 列是 ENUM(category) 类型, 从 ('open_session', 'end_sessio

<p>结果示例如下。</p>

<p><strong>注意</strong>:(<code>'open_session'</code>,<code>'end_session'</code>,<code>'scroll_down'</code>,<code>'send_message'</code>)中的任何活动将被视为用户在某一天活跃的有效活动。</p>

<p>&nbsp;</p>

<p><strong>示例 1:</strong></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Note that each session belongs to exactly one user.

<p>The&nbsp;result format is in the following example.</p>

<p>Note: <strong>Any</strong> activity from (<code>&#39;open_session&#39;</code>, <code>&#39;end_session&#39;</code>, <code>&#39;scroll_down&#39;</code>, <code>&#39;send_message&#39;</code>) will be considered valid activity for a user to be considered active on a day.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,49 @@ tags:

<!-- description:start -->

<p>给你一个整数数组&nbsp;<code>target</code>&nbsp;和一个数组&nbsp;<code>initial</code>&nbsp;,<code>initial</code>&nbsp;数组与 <code>target</code>&nbsp; 数组有同样的维度,且一开始全部为 0 。</p>
<p>给你一个整数数组&nbsp;<code>target</code>&nbsp;和一个数组&nbsp;<code>initial</code>&nbsp;,<code>initial</code>&nbsp;数组与 <code>target</code>&nbsp; 数组有同样的大小,且一开始全部为 0 。</p>

<p>请你返回从 <code>initial</code>&nbsp;得到&nbsp; <code>target</code>&nbsp;的最少操作次数,每次操作需遵循以下规则:</p>
<p>一次操作中,你可以从&nbsp;<code>initial</code> 数组中选择 <strong>任何</strong> 子数组,并将每个值加 <code>1</code></p>

<ul>
<li>在 <code>initial</code>&nbsp;中选择 <strong>任意</strong>&nbsp;子数组,并将子数组中每个元素增加 1 。</li>
</ul>
<p>返回从&nbsp;<code>initial</code>&nbsp;数组构造&nbsp;<code>target</code>&nbsp;数组的最少操作次数。</p>

<p>答案保证在 32 位有符号整数以内。</p>
<p>答案保证在 32 位整数以内。</p>

<p>&nbsp;</p>

<p><strong>示例 1:</strong></p>

<pre><strong>输入:</strong>target = [1,2,3,2,1]
<pre>
<strong>输入:</strong>target = [1,2,3,2,1]
<strong>输出:</strong>3
<strong>解释:</strong>我们需要至少 3 次操作从 intial 数组得到 target 数组。
[0,0,0,0,0] 将下标为 0 到 4&nbsp;的元素(包含二者)加 1 。
[1,1,1,1,1] 将下标为 1 到 3 的元素(包含二者)加 1 。
[1,2,2,2,1] 将下表为 2 的元素增加 1 。
[1,2,2,2,1] 将下标为 2 的元素增加 1 。
[1,2,3,2,1] 得到了目标数组。
</pre>

<p><strong>示例 2:</strong></p>

<pre><strong>输入:</strong>target = [3,1,1,2]
<pre>
<strong>输入:</strong>target = [3,1,1,2]
<strong>输出:</strong>4
<strong>解释:</strong>(initial)[0,0,0,0] -&gt; [1,1,1,1] -&gt; [1,1,1,2] -&gt; [2,1,1,2] -&gt; [3,1,1,2] (target) 。
</pre>

<p><strong>示例 3:</strong></p>

<pre><strong>输入:</strong>target = [3,1,5,4,2]
<pre>
<strong>输入:</strong>target = [3,1,5,4,2]
<strong>输出:</strong>7
<strong>解释:</strong>(initial)[0,0,0,0,0] -&gt; [1,1,1,1,1] -&gt; [2,1,1,1,1] -&gt; [3,1,1,1,1]
-&gt; [3,1,2,2,2] -&gt; [3,1,3,3,2] -&gt; [3,1,4,4,2] -&gt; [3,1,5,4,2] (target)。
</pre>

<p><strong>示例 4:</strong></p>

<pre><strong>输入:</strong>target = [1,1,1,1]
<pre>
<strong>输入:</strong>target = [1,1,1,1]
<strong>输出:</strong>1
</pre>

Expand All @@ -71,8 +73,9 @@ tags:
<p><strong>提示:</strong></p>

<ul>
<li><code>1 &lt;= target.length &lt;= 10^5</code></li>
<li><code>1 &lt;= target[i] &lt;= 10^5</code></li>
<li><code>1 &lt;= target.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= target[i] &lt;= 10<sup>5</sup></code></li>
<li>输入保证答案在 32 位整数范围内。</li>
</ul>

<!-- description:end -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ tags:
<ul>
<li><code>1 &lt;= target.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= target[i] &lt;= 10<sup>5</sup></code></li>
<li>​​​​​​​The input is generated such that the answer fits inside a 32 bit integer.</li>
</ul>

<!-- description:end -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tags:

<p>给定一个字符串列表&nbsp;<code>dict</code> ,其中所有字符串的长度都相同。</p>

<p>当存在两个字符串在相同索引处只有一个字符不同时,返回 <code>True</code> ,否则返回 <code>False</code> 。</p>
<p>当存在两个字符串在相同索引处只有一个字符不同时,返回 <code>true</code> ,否则返回 <code>false</code> 。</p>

<p>&nbsp;</p>

Expand Down Expand Up @@ -52,16 +52,12 @@ tags:
<p><strong>提示:</strong></p>

<ul>
<li><code>dict</code>&nbsp;中的字符数小于或等于&nbsp;<code>10^5</code>&nbsp;。</li>
<li><code>dict</code>&nbsp;中的字符数小于或等于&nbsp;<code>10<sup>5</sup></code>&nbsp;。</li>
<li><code>dict[i].length == dict[j].length</code></li>
<li><code>dict[i]</code>&nbsp;是互不相同的。</li>
<li><code>dict[i]</code>&nbsp;只包含小写英文字母。</li>
</ul>

<p>&nbsp;</p>

<p><strong>进阶:</strong>你可以以 <code>O(n*m)</code> 的复杂度解决问题吗?其中 n 是列表 <code>dict</code> 的长度,<code>m</code> 是字符串的长度。</p>

<!-- description:end -->

## 解法
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ tags:
<li><code>dict[i]</code> contains only lowercase English letters.</li>
</ul>

<p>&nbsp;</p>
<p><strong>Follow up:</strong> Could you solve this problem in <code>O(n * m)</code> where n is the length of <code>dict</code> and <code>m</code> is the length of each string.</p>

<!-- description:end -->

## Solutions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tags:

<ul>
<li>翻转 <code>n</code> 的二进制表示中最右侧位(第 <code>0</code> 位)。</li>
<li>如果第 <code>(i-1)</code> 位为 <code>1</code> 且从第 <code>(i-2)</code> 位到第 <code>0</code> 位都为 <code>0</code>,则翻转 <code>n</code> 的二进制表示中的第 <code>i</code> 位。</li>
<li>如果二进制表示中的第 <code>(i-1)</code> 位为 <code>1</code> 且从第 <code>(i-2)</code> 位到第 <code>0</code> 位都为 <code>0</code>,则翻转 <code>n</code> 的二进制表示中的第 <code>i</code> 位。</li>
</ul>

<p>返回将 <code>n</code> 转换为 <code>0</code> 的最小操作次数。</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tags:
- 树状数组
- 线段树
- 数组
- 哈希表
- 二分查找
- 分治
- 有序集合
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tags:
- Binary Indexed Tree
- Segment Tree
- Array
- Hash Table
- Binary Search
- Divide and Conquer
- Ordered Set
Expand Down
2 changes: 1 addition & 1 deletion solution/2000-2099/2043.Simple Bank System/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ tags:
<p>请你执行所有 <strong>有效的</strong> 交易。如果满足下面全部条件,则交易 <strong>有效</strong> :</p>

<ul>
<li>指定的账户数量在 <code>1</code> 和 <code>n</code> 之间,且</li>
<li>指定的账户编号在 <code>1</code> 和 <code>n</code> 之间,且</li>
<li>取款或者转账需要的钱的总数 <strong>小于或者等于</strong> 账户余额。</li>
</ul>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/2000-2099/2094.Fi
rating: 1454
source: 第 270 场周赛 Q1
tags:
- 递归
- 数组
- 哈希表
- 枚举
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/2000-2099/2094.Fi
rating: 1454
source: Weekly Contest 270 Q1
tags:
- Recursion
- Array
- Hash Table
- Enumeration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tags:

<ul>
<li>在替换之后,同行或同列中的每两个元素的&nbsp;<strong>相对&nbsp;</strong>顺序应该保持&nbsp;<strong>不变</strong>。</li>
<li>替换后矩阵中的 <strong>最大</strong> 数目应尽可能 <strong>小</strong>。</li>
<li>替换后矩阵中的 <strong>最大</strong> 值应尽可能 <strong>小</strong>。</li>
</ul>

<p>如果对于原始矩阵中的所有元素对,使&nbsp;<code>grid[r<sub>1</sub>][c<sub>1</sub>] &gt; grid[r<sub>2</sub>][c<sub>2</sub>]</code>,其中要么&nbsp;<code>r<sub>1</sub> == r<sub>2</sub></code> ,要么&nbsp;<code>c<sub>1</sub> == c<sub>2</sub></code>,则相对顺序保持不变。那么在替换之后一定满足&nbsp;<code>grid[r<sub>1</sub>][c<sub>1</sub>] &gt; grid[r<sub>2</sub>][c<sub>2</sub>]</code>。</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ tags:
<b>解释:</b>
最优方案之一是把 2 座供电站都建在城市 1 。
每座城市的供电站数目分别为 [1,4,4,5,0] 。
- 城市 0 的供电站数目为 1 + 4 = 5 。
- 城市 1 的供电站数目为 1 + 4 + 4 = 9 。
- 城市 2 的供电站数目为 4 + 4 + 5 = 13 。
- 城市 3 的供电站数目为 5 + 4 = 9 。
- 城市 4 的供电站数目为 5 + 0 = 5 。
- 给城市 0 供电的供电站数目为 1 + 4 = 5 。
- 给城市 1 供电的供电站数目为 1 + 4 + 4 = 9 。
- 给城市 2 供电的供电站数目为 4 + 4 + 5 = 13 。
- 给城市 3 供电的供电站数目为 5 + 4 = 9 。
- 给城市 4 供电的供电站数目为 5 + 0 = 5 。
供电站数目最少是 5 。
无法得到更优解,所以我们返回 5 。
</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tags:

<!-- description:start -->

<p>You are given a <strong>0-indexed</strong>&nbsp;array <code>nums</code> consisiting of <strong>positive</strong> integers. You can do the following operation on the array <strong>any</strong> number of times:</p>
<p>You are given a <strong>0-indexed</strong>&nbsp;array <code>nums</code> consisting of <strong>positive</strong> integers. You can do the following operation on the array <strong>any</strong> number of times:</p>

<ul>
<li>Select an index <code>i</code> such that <code>0 &lt;= i &lt; n - 1</code> and replace either of&nbsp;<code>nums[i]</code> or <code>nums[i+1]</code> with their gcd value.</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tags:

<ul>
<li>统计数组中所有元素的出现次数。</li>
<li>仅保留出现次数最多的前 <code>x</code> 个元素的每次出现。如果两个元素的出现次数相同,则数值<strong> 较大 </strong>的元素被认为出现次数更多。</li>
<li>仅保留出现频率最高的前 <code>x</code> 种元素。如果两种元素的出现次数相同,则数值<strong> 较大 </strong>的元素被认为出现次数更多。</li>
<li>计算结果数组的和。</li>
</ul>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tags:

<ul>
<li>统计数组中所有元素的出现次数。</li>
<li>仅保留出现次数最多的前 <code>x</code> 个元素的每次出现。如果两个元素的出现次数相同,则数值<strong> 较大 </strong>的元素被认为出现次数更多。</li>
<li>仅保留出现频率最高的前 <code>x</code> 种元素。如果两种元素的出现次数相同,则数值<strong> 较大 </strong>的元素被认为出现次数更多。</li>
<li>计算结果数组的和。</li>
</ul>

Expand Down
Loading