Skip to content

Commit f1a5421

Browse files
committed
update
1 parent f5bf94d commit f1a5421

23 files changed

+12888
-10797
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 力扣题库(完整版)
22

3-
> 最后更新日期: **2022.05.13**
3+
> 最后更新日期: **2022.05.24**
44
>
55
> 使用脚本前请务必仔细完整阅读本 `README.md` 文件
66

leetcode-cn/origin-data.json

Lines changed: 6334 additions & 6250 deletions
Large diffs are not rendered by default.

leetcode-cn/originData/maximum-bags-with-full-capacity-of-rocks.json

Lines changed: 177 additions & 0 deletions
Large diffs are not rendered by default.

leetcode-cn/originData/minimum-lines-to-represent-a-line-chart.json

Lines changed: 189 additions & 0 deletions
Large diffs are not rendered by default.

leetcode-cn/originData/percentage-of-letter-in-string.json

Lines changed: 165 additions & 0 deletions
Large diffs are not rendered by default.

leetcode-cn/originData/sum-of-total-strength-of-wizards.json

Lines changed: 184 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<p>给你一个字符串 <code>s</code> 和一个字符 <code>letter</code> ,返回在 <code>s</code> 中等于&nbsp;<code>letter</code>&nbsp;字符所占的 <strong>百分比</strong> ,向下取整到最接近的百分比。</p>
2+
3+
<p>&nbsp;</p>
4+
5+
<p><strong>示例 1:</strong></p>
6+
7+
<pre>
8+
<strong>输入:</strong>s = "foobar", letter = "o"
9+
<strong>输出:</strong>33
10+
<strong>解释:</strong>
11+
等于字母 'o' 的字符在 s 中占到的百分比是 2 / 6 * 100% = 33% ,向下取整,所以返回 33 。
12+
</pre>
13+
14+
<p><strong>示例 2:</strong></p>
15+
16+
<pre>
17+
<strong>输入:</strong>s = "jjjj", letter = "k"
18+
<strong>输出:</strong>0
19+
<strong>解释:</strong>
20+
等于字母 'k' 的字符在 s 中占到的百分比是 0% ,所以返回 0 。</pre>
21+
22+
<p>&nbsp;</p>
23+
24+
<p><strong>提示:</strong></p>
25+
26+
<ul>
27+
<li><code>1 &lt;= s.length &lt;= 100</code></li>
28+
<li><code>s</code> 由小写英文字母组成</li>
29+
<li><code>letter</code> 是一个小写英文字母</li>
30+
</ul>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<p>作为国王的统治者,你有一支巫师军队听你指挥。</p>
2+
3+
<p>给你一个下标从 <strong>0</strong>&nbsp;开始的整数数组&nbsp;<code>strength</code>&nbsp;,其中&nbsp;<code>strength[i]</code>&nbsp;表示第&nbsp;<code>i</code>&nbsp;位巫师的力量值。对于连续的一组巫师(也就是这些巫师的力量值是&nbsp;<code>strength</code>&nbsp;的&nbsp;<strong>子数组</strong>),<strong>总力量</strong>&nbsp;定义为以下两个值的&nbsp;<strong>乘积</strong>&nbsp;:</p>
4+
5+
<ul>
6+
<li>巫师中 <strong>最弱</strong>&nbsp;的能力值。</li>
7+
<li>组中所有巫师的个人力量值 <strong>之和</strong>&nbsp;。</li>
8+
</ul>
9+
10+
<p>请你返回 <strong>所有</strong>&nbsp;巫师组的 <strong></strong>&nbsp;力量之和。由于答案可能很大,请将答案对&nbsp;<code>10<sup>9</sup> + 7</code>&nbsp;<strong>取余</strong>&nbsp;后返回。</p>
11+
12+
<p><strong>子数组</strong>&nbsp;是一个数组里 <strong>非空</strong>&nbsp;连续子序列。</p>
13+
14+
<p>&nbsp;</p>
15+
16+
<p><strong>示例 1:</strong></p>
17+
18+
<pre><b>输入:</b>strength = [1,3,1,2]
19+
<b>输出:</b>44
20+
<b>解释:</b>以下是所有连续巫师组:
21+
- [<em><strong>1</strong></em>,3,1,2] 中 [1] ,总力量值为 min([1]) * sum([1]) = 1 * 1 = 1
22+
- [1,<em><strong>3</strong></em>,1,2] 中 [3] ,总力量值为 min([3]) * sum([3]) = 3 * 3 = 9
23+
- [1,3,<em><strong>1</strong></em>,2] 中 [1] ,总力量值为 min([1]) * sum([1]) = 1 * 1 = 1
24+
- [1,3,1,<em><strong>2</strong></em>] 中 [2] ,总力量值为 min([2]) * sum([2]) = 2 * 2 = 4
25+
- [<em><strong>1,3</strong></em>,1,2] 中 [1,3] ,总力量值为 min([1,3]) * sum([1,3]) = 1 * 4 = 4
26+
- [1,<em><strong>3,1</strong></em>,2] 中 [3,1] ,总力量值为 min([3,1]) * sum([3,1]) = 1 * 4 = 4
27+
- [1,3,<em><strong>1,2</strong></em>] 中 [1,2] ,总力量值为 min([1,2]) * sum([1,2]) = 1 * 3 = 3
28+
- [<em><strong>1,3,1</strong></em>,2] 中 [1,3,1] ,总力量值为 min([1,3,1]) * sum([1,3,1]) = 1 * 5 = 5
29+
- [1,<em><strong>3,1,2</strong></em>] 中 [3,1,2] ,总力量值为 min([3,1,2]) * sum([3,1,2]) = 1 * 6 = 6
30+
- [<em><strong>1,3,1,2</strong></em>] 中 [1,3,1,2] ,总力量值为 min([1,3,1,2]) * sum([1,3,1,2]) = 1 * 7 = 7
31+
所有力量值之和为 1 + 9 + 1 + 4 + 4 + 4 + 3 + 5 + 6 + 7 = 44 。
32+
</pre>
33+
34+
<p><strong>示例 2:</strong></p>
35+
36+
<pre><b>输入:</b>strength = [5,4,6]
37+
<b>输出:</b>213
38+
<b>解释:</b>以下是所有连续巫师组:
39+
- [<em><strong>5</strong></em>,4,6] 中 [5] ,总力量值为 min([5]) * sum([5]) = 5 * 5 = 25
40+
- [5,<em><strong>4</strong></em>,6] 中 [4] ,总力量值为 min([4]) * sum([4]) = 4 * 4 = 16
41+
- [5,4,<em><strong>6</strong></em>] 中 [6] ,总力量值为 min([6]) * sum([6]) = 6 * 6 = 36
42+
- [<em><strong>5,4</strong></em>,6] 中 [5,4] ,总力量值为 min([5,4]) * sum([5,4]) = 4 * 9 = 36
43+
- [5,<em><strong>4,6</strong></em>] 中 [4,6] ,总力量值为 min([4,6]) * sum([4,6]) = 4 * 10 = 40
44+
- [<em><strong>5,4,6</strong></em>] 中 [5,4,6] ,总力量值为 min([5,4,6]) * sum([5,4,6]) = 4 * 15 = 60
45+
所有力量值之和为 25 + 16 + 36 + 36 + 40 + 60 = 213 。
46+
</pre>
47+
48+
<p>&nbsp;</p>
49+
50+
<p><strong>提示:</strong></p>
51+
52+
<ul>
53+
<li><code>1 &lt;= strength.length &lt;= 10<sup>5</sup></code></li>
54+
<li><code>1 &lt;= strength[i] &lt;= 10<sup>9</sup></code></li>
55+
</ul>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<p>给你一个二维整数数组&nbsp;<code>stockPrices</code> ,其中&nbsp;<code>stockPrices[i] = [day<sub>i</sub>, price<sub>i</sub>]</code>&nbsp;表示股票在&nbsp;<code>day<sub>i</sub></code>&nbsp;的价格为&nbsp;<code>price<sub>i</sub></code>&nbsp;。<strong>折线图</strong>&nbsp;是一个二维平面上的若干个点组成的图,横坐标表示日期,纵坐标表示价格,折线图由相邻的点连接而成。比方说下图是一个例子:</p>
2+
<img alt="" src="https://assets.leetcode.com/uploads/2022/03/30/1920px-pushkin_population_historysvg.png" style="width: 500px; height: 313px;">
3+
<p>请你返回要表示一个折线图所需要的 <strong>最少线段数</strong>&nbsp;。</p>
4+
5+
<p>&nbsp;</p>
6+
7+
<p><strong>示例 1:</strong></p>
8+
9+
<p><img alt="" src="https://assets.leetcode.com/uploads/2022/03/30/ex0.png" style="width: 400px; height: 400px;"></p>
10+
11+
<pre><b>输入:</b>stockPrices = [[1,7],[2,6],[3,5],[4,4],[5,4],[6,3],[7,2],[8,1]]
12+
<b>输出:</b>3
13+
<strong>解释:</strong>
14+
上图为输入对应的图,横坐标表示日期,纵坐标表示价格。
15+
以下 3 个线段可以表示折线图:
16+
- 线段 1 (红色)从 (1,7) 到 (4,4) ,经过 (1,7) ,(2,6) ,(3,5) 和 (4,4) 。
17+
- 线段 2 (蓝色)从 (4,4) 到 (5,4) 。
18+
- 线段 3 (绿色)从 (5,4) 到 (8,1) ,经过 (5,4) ,(6,3) ,(7,2) 和 (8,1) 。
19+
可以证明,无法用少于 3 条线段表示这个折线图。
20+
</pre>
21+
22+
<p><strong>示例 2:</strong></p>
23+
24+
<p><img alt="" src="https://assets.leetcode.com/uploads/2022/03/30/ex1.png" style="width: 325px; height: 325px;"></p>
25+
26+
<pre><b>输入:</b>stockPrices = [[3,4],[1,2],[7,8],[2,3]]
27+
<b>输出:</b>1
28+
<strong>解释:</strong>
29+
如上图所示,折线图可以用一条线段表示。
30+
</pre>
31+
32+
<p>&nbsp;</p>
33+
34+
<p><strong>提示:</strong></p>
35+
36+
<ul>
37+
<li><code>1 &lt;= stockPrices.length &lt;= 10<sup>5</sup></code></li>
38+
<li><code>stockPrices[i].length == 2</code></li>
39+
<li><code>1 &lt;= day<sub>i</sub>, price<sub>i</sub> &lt;= 10<sup>9</sup></code></li>
40+
<li>所有&nbsp;<code>day<sub>i</sub></code>&nbsp;<strong>互不相同</strong>&nbsp;。</li>
41+
</ul>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<p>现有编号从&nbsp;<code>0</code><code>n - 1</code><code>n</code> 个背包。给你两个下标从 <strong>0</strong> 开始的整数数组 <code>capacity</code><code>rocks</code> 。第 <code>i</code> 个背包最大可以装 <code>capacity[i]</code> 块石头,当前已经装了 <code>rocks[i]</code> 块石头。另给你一个整数 <code>additionalRocks</code> ,表示<span class="text-only" data-eleid="10" style="white-space: pre;">你可以放置的额外石头数量,石头可以往 </span><strong><span class="text-only" data-eleid="11" style="white-space: pre;">任意</span></strong><span class="text-only" data-eleid="12" style="white-space: pre;"> 背包中放置。</span></p>
2+
3+
<p>请你将额外的石头放入一些背包中,并返回放置后装满石头的背包的 <strong>最大 </strong>数量<em></em></p>
4+
5+
<p>&nbsp;</p>
6+
7+
<p><strong>示例 1:</strong></p>
8+
9+
<pre>
10+
<strong>输入:</strong>capacity = [2,3,4,5], rocks = [1,2,4,4], additionalRocks = 2
11+
<strong>输出:</strong>3
12+
<strong>解释:</strong>
13+
1 块石头放入背包 0 ,1 块石头放入背包 1 。
14+
每个背包中的石头总数是 [2,3,4,4] 。
15+
背包 0 、背包 1 和 背包 2 都装满石头。
16+
总计 3 个背包装满石头,所以返回 3 。
17+
可以证明不存在超过 3 个背包装满石头的情况。
18+
注意,可能存在其他放置石头的方案同样能够得到 3 这个结果。
19+
</pre>
20+
21+
<p><strong>示例 2:</strong></p>
22+
23+
<pre>
24+
<strong>输入:</strong>capacity = [10,2,2], rocks = [2,2,0], additionalRocks = 100
25+
<strong>输出:</strong>3
26+
<strong>解释:</strong>
27+
8 块石头放入背包 0 ,2 块石头放入背包 2 。
28+
每个背包中的石头总数是 [10,2,2] 。
29+
背包 0 、背包 1 和背包 2 都装满石头。
30+
总计 3 个背包装满石头,所以返回 3 。
31+
可以证明不存在超过 3 个背包装满石头的情况。
32+
注意,不必用完所有的额外石头。
33+
</pre>
34+
35+
<p>&nbsp;</p>
36+
37+
<p><strong>提示:</strong></p>
38+
39+
<ul>
40+
<li><code>n == capacity.length == rocks.length</code></li>
41+
<li><code>1 &lt;= n &lt;= 5 * 10<sup>4</sup></code></li>
42+
<li><code>1 &lt;= capacity[i] &lt;= 10<sup>9</sup></code></li>
43+
<li><code>0 &lt;= rocks[i] &lt;= capacity[i]</code></li>
44+
<li><code>1 &lt;= additionalRocks &lt;= 10<sup>9</sup></code></li>
45+
</ul>

0 commit comments

Comments
 (0)