Skip to content

Commit f1a5421

Browse files
committed
update
1 parent f5bf94d commit f1a5421

23 files changed

+12888
-10797
lines changed

README.md

+1-1
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

+6,334-6,250
Large diffs are not rendered by default.

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

+177
Large diffs are not rendered by default.

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

+189
Large diffs are not rendered by default.

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

+165
Large diffs are not rendered by default.

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

+184
Large diffs are not rendered by default.
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>
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>
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>
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>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<p>Given a string <code>s</code> and a character <code>letter</code>, return<em> the <strong>percentage</strong> of characters in </em><code>s</code><em> that equal </em><code>letter</code><em> <strong>rounded down</strong> to the nearest whole percent.</em></p>
2+
3+
<p>&nbsp;</p>
4+
<p><strong>Example 1:</strong></p>
5+
6+
<pre>
7+
<strong>Input:</strong> s = &quot;foobar&quot;, letter = &quot;o&quot;
8+
<strong>Output:</strong> 33
9+
<strong>Explanation:</strong>
10+
The percentage of characters in s that equal the letter &#39;o&#39; is 2 / 6 * 100% = 33% when rounded down, so we return 33.
11+
</pre>
12+
13+
<p><strong>Example 2:</strong></p>
14+
15+
<pre>
16+
<strong>Input:</strong> s = &quot;jjjj&quot;, letter = &quot;k&quot;
17+
<strong>Output:</strong> 0
18+
<strong>Explanation:</strong>
19+
The percentage of characters in s that equal the letter &#39;k&#39; is 0%, so we return 0.</pre>
20+
21+
<p>&nbsp;</p>
22+
<p><strong>Constraints:</strong></p>
23+
24+
<ul>
25+
<li><code>1 &lt;= s.length &lt;= 100</code></li>
26+
<li><code>s</code> consists of lowercase English letters.</li>
27+
<li><code>letter</code> is a lowercase English letter.</li>
28+
</ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<p>As the ruler of a kingdom, you have an army of wizards at your command.</p>
2+
3+
<p>You are given a <strong>0-indexed</strong> integer array <code>strength</code>, where <code>strength[i]</code> denotes the strength of the <code>i<sup>th</sup></code> wizard. For a <strong>contiguous</strong> group of wizards (i.e. the wizards&#39; strengths form a <strong>subarray</strong> of <code>strength</code>), the <strong>total strength</strong> is defined as the <strong>product</strong> of the following two values:</p>
4+
5+
<ul>
6+
<li>The strength of the <strong>weakest</strong> wizard in the group.</li>
7+
<li>The <strong>total</strong> of all the individual strengths of the wizards in the group.</li>
8+
</ul>
9+
10+
<p>Return <em>the <strong>sum</strong> of the total strengths of <strong>all</strong> contiguous groups of wizards</em>. Since the answer may be very large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>
11+
12+
<p>A <strong>subarray</strong> is a contiguous <strong>non-empty</strong> sequence of elements within an array.</p>
13+
14+
<p>&nbsp;</p>
15+
<p><strong>Example 1:</strong></p>
16+
17+
<pre>
18+
<strong>Input:</strong> strength = [1,3,1,2]
19+
<strong>Output:</strong> 44
20+
<strong>Explanation:</strong> The following are all the contiguous groups of wizards:
21+
- [1] from [<u><strong>1</strong></u>,3,1,2] has a total strength of min([1]) * sum([1]) = 1 * 1 = 1
22+
- [3] from [1,<u><strong>3</strong></u>,1,2] has a total strength of min([3]) * sum([3]) = 3 * 3 = 9
23+
- [1] from [1,3,<u><strong>1</strong></u>,2] has a total strength of min([1]) * sum([1]) = 1 * 1 = 1
24+
- [2] from [1,3,1,<u><strong>2</strong></u>] has a total strength of min([2]) * sum([2]) = 2 * 2 = 4
25+
- [1,3] from [<u><strong>1,3</strong></u>,1,2] has a total strength of min([1,3]) * sum([1,3]) = 1 * 4 = 4
26+
- [3,1] from [1,<u><strong>3,1</strong></u>,2] has a total strength of min([3,1]) * sum([3,1]) = 1 * 4 = 4
27+
- [1,2] from [1,3,<u><strong>1,2</strong></u>] has a total strength of min([1,2]) * sum([1,2]) = 1 * 3 = 3
28+
- [1,3,1] from [<u><strong>1,3,1</strong></u>,2] has a total strength of min([1,3,1]) * sum([1,3,1]) = 1 * 5 = 5
29+
- [3,1,2] from [1,<u><strong>3,1,2</strong></u>] has a total strength of min([3,1,2]) * sum([3,1,2]) = 1 * 6 = 6
30+
- [1,3,1,2] from [<u><strong>1,3,1,2</strong></u>] has a total strength of min([1,3,1,2]) * sum([1,3,1,2]) = 1 * 7 = 7
31+
The sum of all the total strengths is 1 + 9 + 1 + 4 + 4 + 4 + 3 + 5 + 6 + 7 = 44.
32+
</pre>
33+
34+
<p><strong>Example 2:</strong></p>
35+
36+
<pre>
37+
<strong>Input:</strong> strength = [5,4,6]
38+
<strong>Output:</strong> 213
39+
<strong>Explanation:</strong> The following are all the contiguous groups of wizards:
40+
- [5] from [<u><strong>5</strong></u>,4,6] has a total strength of min([5]) * sum([5]) = 5 * 5 = 25
41+
- [4] from [5,<u><strong>4</strong></u>,6] has a total strength of min([4]) * sum([4]) = 4 * 4 = 16
42+
- [6] from [5,4,<u><strong>6</strong></u>] has a total strength of min([6]) * sum([6]) = 6 * 6 = 36
43+
- [5,4] from [<u><strong>5,4</strong></u>,6] has a total strength of min([5,4]) * sum([5,4]) = 4 * 9 = 36
44+
- [4,6] from [5,<u><strong>4,6</strong></u>] has a total strength of min([4,6]) * sum([4,6]) = 4 * 10 = 40
45+
- [5,4,6] from [<u><strong>5,4,6</strong></u>] has a total strength of min([5,4,6]) * sum([5,4,6]) = 4 * 15 = 60
46+
The sum of all the total strengths is 25 + 16 + 36 + 36 + 40 + 60 = 213.
47+
</pre>
48+
49+
<p>&nbsp;</p>
50+
<p><strong>Constraints:</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>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<p>You are given a 2D integer array <code>stockPrices</code> where <code>stockPrices[i] = [day<sub>i</sub>, price<sub>i</sub>]</code> indicates the price of the stock on day <code>day<sub>i</sub></code> is <code>price<sub>i</sub></code>. A <strong>line chart</strong> is created from the array by plotting the points on an XY plane with the X-axis representing the day and the Y-axis representing the price and connecting adjacent points. One such example is shown below:</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>Return <em>the <strong>minimum number of lines</strong> needed to represent the line chart</em>.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong>Example 1:</strong></p>
7+
<img alt="" src="https://assets.leetcode.com/uploads/2022/03/30/ex0.png" style="width: 400px; height: 400px;" />
8+
<pre>
9+
<strong>Input:</strong> stockPrices = [[1,7],[2,6],[3,5],[4,4],[5,4],[6,3],[7,2],[8,1]]
10+
<strong>Output:</strong> 3
11+
<strong>Explanation:</strong>
12+
The diagram above represents the input, with the X-axis representing the day and Y-axis representing the price.
13+
The following 3 lines can be drawn to represent the line chart:
14+
- Line 1 (in red) from (1,7) to (4,4) passing through (1,7), (2,6), (3,5), and (4,4).
15+
- Line 2 (in blue) from (4,4) to (5,4).
16+
- Line 3 (in green) from (5,4) to (8,1) passing through (5,4), (6,3), (7,2), and (8,1).
17+
It can be shown that it is not possible to represent the line chart using less than 3 lines.
18+
</pre>
19+
20+
<p><strong>Example 2:</strong></p>
21+
<img alt="" src="https://assets.leetcode.com/uploads/2022/03/30/ex1.png" style="width: 325px; height: 325px;" />
22+
<pre>
23+
<strong>Input:</strong> stockPrices = [[3,4],[1,2],[7,8],[2,3]]
24+
<strong>Output:</strong> 1
25+
<strong>Explanation:</strong>
26+
As shown in the diagram above, the line chart can be represented with a single line.
27+
</pre>
28+
29+
<p>&nbsp;</p>
30+
<p><strong>Constraints:</strong></p>
31+
32+
<ul>
33+
<li><code>1 &lt;= stockPrices.length &lt;= 10<sup>5</sup></code></li>
34+
<li><code>stockPrices[i].length == 2</code></li>
35+
<li><code>1 &lt;= day<sub>i</sub>, price<sub>i</sub> &lt;= 10<sup>9</sup></code></li>
36+
<li>All <code>day<sub>i</sub></code> are <strong>distinct</strong>.</li>
37+
</ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<p>You have <code>n</code> bags numbered from <code>0</code> to <code>n - 1</code>. You are given two <strong>0-indexed</strong> integer arrays <code>capacity</code> and <code>rocks</code>. The <code>i<sup>th</sup></code> bag can hold a maximum of <code>capacity[i]</code> rocks and currently contains <code>rocks[i]</code> rocks. You are also given an integer <code>additionalRocks</code>, the number of additional rocks you can place in <strong>any</strong> of the bags.</p>
2+
3+
<p>Return<em> the <strong>maximum</strong> number of bags that could have full capacity after placing the additional rocks in some bags.</em></p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong>Example 1:</strong></p>
7+
8+
<pre>
9+
<strong>Input:</strong> capacity = [2,3,4,5], rocks = [1,2,4,4], additionalRocks = 2
10+
<strong>Output:</strong> 3
11+
<strong>Explanation:</strong>
12+
Place 1 rock in bag 0 and 1 rock in bag 1.
13+
The number of rocks in each bag are now [2,3,4,4].
14+
Bags 0, 1, and 2 have full capacity.
15+
There are 3 bags at full capacity, so we return 3.
16+
It can be shown that it is not possible to have more than 3 bags at full capacity.
17+
Note that there may be other ways of placing the rocks that result in an answer of 3.
18+
</pre>
19+
20+
<p><strong>Example 2:</strong></p>
21+
22+
<pre>
23+
<strong>Input:</strong> capacity = [10,2,2], rocks = [2,2,0], additionalRocks = 100
24+
<strong>Output:</strong> 3
25+
<strong>Explanation:</strong>
26+
Place 8 rocks in bag 0 and 2 rocks in bag 2.
27+
The number of rocks in each bag are now [10,2,2].
28+
Bags 0, 1, and 2 have full capacity.
29+
There are 3 bags at full capacity, so we return 3.
30+
It can be shown that it is not possible to have more than 3 bags at full capacity.
31+
Note that we did not use all of the additional rocks.
32+
</pre>
33+
34+
<p>&nbsp;</p>
35+
<p><strong>Constraints:</strong></p>
36+
37+
<ul>
38+
<li><code>n == capacity.length == rocks.length</code></li>
39+
<li><code>1 &lt;= n &lt;= 5 * 10<sup>4</sup></code></li>
40+
<li><code>1 &lt;= capacity[i] &lt;= 10<sup>9</sup></code></li>
41+
<li><code>0 &lt;= rocks[i] &lt;= capacity[i]</code></li>
42+
<li><code>1 &lt;= additionalRocks &lt;= 10<sup>9</sup></code></li>
43+
</ul>

0 commit comments

Comments
 (0)