Skip to content

Commit 7d7863a

Browse files
authoredSep 25, 2024··
feat: update lc problems (#3561)
1 parent 51350fe commit 7d7863a

File tree

31 files changed

+181
-145
lines changed

31 files changed

+181
-145
lines changed
 

‎solution/0000-0099/0063.Unique Paths II/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ tags:
1818

1919
<!-- description:start -->
2020

21-
<p>一个机器人位于一个<meta charset="UTF-8" />&nbsp;<code>m x n</code>&nbsp;网格的左上角 (起始点在下图中标记为 “Start” )。</p>
21+
<p>给定一个&nbsp;<code>m x n</code>&nbsp;的整数数组&nbsp;<code>grid</code>。一个机器人初始位于 <strong>左上角</strong>(即 <code>grid[0][0]</code>)。机器人尝试移动到 <strong>右下角</strong>(即 <code>grid[m - 1][n - 1]</code>)。机器人每次只能向下或者向右移动一步。</p>
2222

23-
<p>机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为 “Finish”)。</p>
23+
<p>网格中的障碍物和空位置分别用 <code>1</code> 和 <code>0</code> 来表示。机器人的移动路径中不能包含 <strong>任何</strong>&nbsp;有障碍物的方格。</p>
2424

25-
<p>现在考虑网格中有障碍物。那么从左上角到右下角将会有多少条不同的路径?</p>
25+
<p>返回机器人能够到达右下角的不同路径数量。</p>
2626

27-
<p>网格中的障碍物和空位置分别用 <code>1</code> 和 <code>0</code> 来表示。</p>
27+
<p>测试用例保证答案小于等于 <code>2 * 10<sup>9</sup></code>。</p>
2828

2929
<p>&nbsp;</p>
3030

‎solution/0100-0199/0191.Number of 1 Bits/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ tags:
4242
<pre>
4343
<strong>输入:</strong>n = 2147483645
4444
<strong>输出:</strong>30
45-
<strong>解释:</strong>输入的二进制串 <strong>11111111111111111111111111111101</strong> 中,共有 30 个设置位。</pre>
45+
<strong>解释:</strong>输入的二进制串 <strong>1111111111111111111111111111101</strong> 中,共有 30 个设置位。</pre>
4646

4747
<p>&nbsp;</p>
4848

‎solution/0300-0399/0314.Binary Tree Vertical Order Traversal/README_EN.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@ tags:
2727

2828
<p>&nbsp;</p>
2929
<p><strong class="example">Example 1:</strong></p>
30-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0300-0399/0314.Binary%20Tree%20Vertical%20Order%20Traversal/images/vtree1.jpg" style="width: 282px; height: 301px;" />
30+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0300-0399/0314.Binary%20Tree%20Vertical%20Order%20Traversal/images/image1.png" style="width: 400px; height: 273px;" />
3131
<pre>
3232
<strong>Input:</strong> root = [3,9,20,null,null,15,7]
3333
<strong>Output:</strong> [[9],[3,15],[20],[7]]
3434
</pre>
3535

3636
<p><strong class="example">Example 2:</strong></p>
37-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0300-0399/0314.Binary%20Tree%20Vertical%20Order%20Traversal/images/vtree2-1.jpg" style="width: 462px; height: 222px;" />
37+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0300-0399/0314.Binary%20Tree%20Vertical%20Order%20Traversal/images/image3.png" style="width: 450px; height: 285px;" />
3838
<pre>
3939
<strong>Input:</strong> root = [3,9,8,4,0,1,7]
4040
<strong>Output:</strong> [[4],[9],[3,0,1],[8],[7]]
4141
</pre>
4242

4343
<p><strong class="example">Example 3:</strong></p>
44-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0300-0399/0314.Binary%20Tree%20Vertical%20Order%20Traversal/images/vtree2.jpg" style="width: 462px; height: 302px;" />
44+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0300-0399/0314.Binary%20Tree%20Vertical%20Order%20Traversal/images/image2.png" style="width: 350px; height: 342px;" />
4545
<pre>
46-
<strong>Input:</strong> root = [3,9,8,4,0,1,7,null,null,null,2,5]
47-
<strong>Output:</strong> [[4],[9,5],[3,0,1],[8,2],[7]]
46+
<strong>Input:</strong> root = [1,2,3,4,10,9,11,null,5,null,null,null,null,null,null,null,6]
47+
<strong>Output:</strong> [[4],[2,5],[1,10,9,6],[3],[11]]
4848
</pre>
4949

5050
<p>&nbsp;</p>
Loading
Loading
Loading

‎solution/0400-0499/0428.Serialize and Deserialize N-ary Tree/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ tags:
2727

2828
<p>&nbsp;</p>
2929

30-
<p><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0400-0499/0428.Serialize%20and%20Deserialize%20N-ary%20Tree/images/narytreeexample.png" style="height: 321px; width: 500px;" /></p>
30+
<p><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0400-0499/0428.Serialize%20and%20Deserialize%20N-ary%20Tree/images/1727093143-BPVnoI-image.png" style="height: 321px; width: 500px;" /></p>
3131

3232
<p>&nbsp;</p>
3333

3434
<p>为&nbsp;<code>[1 [3[5 6] 2 4]]</code>。你不需要以这种形式完成,你可以自己创造和实现不同的方法。</p>
3535

3636
<p>或者,您可以遵循 LeetCode 的层序遍历序列化格式,其中每组孩子节点由空值分隔。</p>
3737

38-
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0400-0499/0428.Serialize%20and%20Deserialize%20N-ary%20Tree/images/sample_4_964.png" style="height: 454px; width: 500px;" /></p>
38+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0400-0499/0428.Serialize%20and%20Deserialize%20N-ary%20Tree/images/1727093169-WGFOps-image.png" style="height: 454px; width: 500px;" /></p>
3939

4040
<p>例如,上面的树可以序列化为 <code>[1,null,2,3,4,5,null,null,6,7,null,8,null,9,10,null,null,11,null,12,null,13,null,null,14]</code></p>
4141

‎solution/0900-0999/0929.Unique Email Addresses/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ tags:
6767
<li>每个 <code>emails[i]</code> 都包含有且仅有一个 <code>'@'</code> 字符</li>
6868
<li>所有本地名和域名都不为空</li>
6969
<li>本地名不会以 <code>'+'</code> 字符作为开头</li>
70+
<li>域名以&nbsp;<code>".com"</code> 后缀结尾。</li>
71+
<li>域名在&nbsp;<code>".com"</code> 后缀前至少包含一个字符</li>
7072
</ul>
7173

7274
<!-- description:end -->

‎solution/0900-0999/0929.Unique Email Addresses/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ tags:
6767
<li>All local and domain names are non-empty.</li>
6868
<li>Local names do not start with a <code>&#39;+&#39;</code> character.</li>
6969
<li>Domain names end with the <code>&quot;.com&quot;</code> suffix.</li>
70+
<li>Domain names must contain at least one character before <code>&quot;.com&quot;</code> suffix.</li>
7071
</ul>
7172

7273
<!-- description:end -->

‎solution/1200-1299/1211.Queries Quality and Percentage/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ tags:
4141
<p>各查询结果的评分与其位置之间比率的平均值。</p>
4242
</blockquote>
4343

44-
<p>将劣质查询百分比&nbsp;<code>poor_query_percentage</code>:</p>
44+
<p>将劣质查询百分比&nbsp;<code>poor_query_percentage</code>&nbsp;定义为:</p>
4545

4646
<blockquote>
4747
<p>评分小于 3 的查询结果占全部查询结果的百分比。</p>

‎solution/1600-1699/1666.Change the Root of a Binary Tree/README.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,44 @@ tags:
1818

1919
<!-- description:start -->
2020

21-
<p>给定一棵二叉树的根节点 <code>root</code> 和一个叶节点 <code>leaf</code> ,更改二叉树,使得 <code>leaf</code> 为新的根节点。</p>
21+
<p>给定一棵二叉树的根节点&nbsp;<code>root</code>&nbsp;和一个叶节点&nbsp;<code>leaf</code> ,更改二叉树,使得&nbsp;<code>leaf</code>&nbsp;为新的根节点。</p>
2222

23-
<p>你可以按照下列步骤修改<strong>从</strong> <code>leaf</code> <strong>到</strong> <code>root</code> <strong>的路径中除</strong> <code>root</code> <strong>外的每个节点</strong> <code>cur</code> :</p>
23+
<p>你可以按照下列步骤修改<strong>从</strong> <code>leaf</code>&nbsp;<strong>到</strong> <code>root</code>&nbsp;<strong>的路径中除</strong> <code>root</code> <strong>外的每个节点</strong> <code>cur</code>&nbsp;:</p>
2424

2525
<ol>
26-
<li>如果 <code>cur</code> 有左子节点,则该子节点变为 <code>cur</code> 的右子节点。注意我们保证 <code>cur</code> 至多有一个子节点。</li>
27-
<li><code>cur</code> 的原父节点变为 <code>cur</code> 的左子节点。</li>
26+
<li>如果&nbsp;<code>cur</code>&nbsp;有左子节点,则该子节点变为&nbsp;<code>cur</code>&nbsp;的右子节点。注意我们保证&nbsp;<code>cur</code>&nbsp;至多有一个子节点。</li>
27+
<li><code>cur</code>&nbsp;的原父节点变为&nbsp;<code>cur</code>&nbsp;的左子节点。</li>
2828
</ol>
2929

3030
<p>返回修改后新树的根节点。</p>
3131

32-
<p><b>注意:</b>确保你的答案在操作后正确地设定了 <code>Node.parent</code> (父节点)指针,否则会被判为错误答案。</p>
32+
<p><b>注意:</b>确保你的答案在操作后正确地设定了&nbsp;<code>Node.parent</code>&nbsp;(父节点)指针,否则会被判为错误答案。</p>
3333

34-
<p> </p>
34+
<p>&nbsp;</p>
3535

3636
<p><strong>示例 1:</strong></p>
37-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1600-1699/1666.Change%20the%20Root%20of%20a%20Binary%20Tree/images/fliptree.png" style="width: 400px; height: 298px;">
38-
<pre><strong>输入:</strong> root = [3,5,1,6,2,0,8,null,null,7,4], leaf = 7
37+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1600-1699/1666.Change%20the%20Root%20of%20a%20Binary%20Tree/images/1727138189-YtDgTf-image.png" style="width: 500px; height: 262px;" />
38+
<pre>
39+
<strong>输入:</strong> root = [3,5,1,6,2,0,8,null,null,7,4], leaf = 7
3940
<strong>输出:</strong> [7,2,null,5,4,3,6,null,null,null,1,null,null,0,8]
4041
</pre>
4142

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

44-
<pre><strong>输入:</strong> root = [3,5,1,6,2,0,8,null,null,7,4], leaf = 0
45+
<pre>
46+
<strong>输入:</strong> root = [3,5,1,6,2,0,8,null,null,7,4], leaf = 0
4547
<strong>输出:</strong> [0,1,null,3,8,5,null,null,null,6,2,null,null,7,4]
4648
</pre>
4749

48-
<p> </p>
50+
<p>&nbsp;</p>
4951

5052
<p><strong>提示:</strong></p>
5153

5254
<ul>
53-
<li>树中节点的个数在范围 <code>[2, 100]</code> 内。</li>
55+
<li>树中节点的个数在范围&nbsp;<code>[2, 100]</code>&nbsp;内。</li>
5456
<li><code>-10<sup>9</sup> &lt;= Node.val &lt;= 10<sup>9</sup></code></li>
55-
<li>所有的 <code>Node.val</code> 都是<strong>唯一</strong>的。</li>
56-
<li><code>leaf</code> 存在于树中。</li>
57+
<li>所有的&nbsp;<code>Node.val</code>&nbsp;都是<strong>唯一</strong>的。</li>
58+
<li><code>leaf</code>&nbsp;存在于树中。</li>
5759
</ul>
5860

5961
<!-- description:end -->

‎solution/1600-1699/1666.Change the Root of a Binary Tree/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ tags:
3333

3434
<p>&nbsp;</p>
3535
<p><strong class="example">Example 1:</strong></p>
36-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1600-1699/1666.Change%20the%20Root%20of%20a%20Binary%20Tree/images/fliptree.png" style="width: 400px; height: 298px;" />
36+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1600-1699/1666.Change%20the%20Root%20of%20a%20Binary%20Tree/images/bt_image_1.png" style="width: 500px; height: 262px;" />
3737
<pre>
3838
<strong>Input:</strong> root = [3,5,1,6,2,0,8,null,null,7,4], leaf = 7
3939
<strong>Output:</strong> [7,2,null,5,4,3,6,null,null,null,1,null,null,0,8]
Loading
Loading
Binary file not shown.

‎solution/1800-1899/1858.Longest Word With All Prefixes/README_EN.md

+5-24
Original file line numberDiff line numberDiff line change
@@ -20,63 +20,44 @@ tags:
2020
<p>Given an array of strings <code>words</code>, find the <strong>longest</strong> string in <code>words</code> such that <strong>every prefix</strong> of it is also in <code>words</code>.</p>
2121

2222
<ul>
23-
24-
<li>For example, let <code>words = [&quot;a&quot;, &quot;app&quot;, &quot;ap&quot;]</code>. The string <code>&quot;app&quot;</code> has prefixes <code>&quot;ap&quot;</code> and <code>&quot;a&quot;</code>, all of which are in <code>words</code>.</li>
25-
23+
<li>For example, let <code>words = [&quot;a&quot;, &quot;app&quot;, &quot;ap&quot;]</code>. The string <code>&quot;app&quot;</code> has prefixes <code>&quot;ap&quot;</code> and <code>&quot;a&quot;</code>, all of which are in <code>words</code>.</li>
2624
</ul>
2725

2826
<p>Return <em>the string described above. If there is more than one string with the same length, return the <strong>lexicographically smallest</strong> one, and if no string exists, return </em><code>&quot;&quot;</code>.</p>
2927

3028
<p>&nbsp;</p>
31-
3229
<p><strong class="example">Example 1:</strong></p>
3330

3431
<pre>
35-
3632
<strong>Input:</strong> words = [&quot;k&quot;,&quot;ki&quot;,&quot;kir&quot;,&quot;kira&quot;, &quot;kiran&quot;]
37-
3833
<strong>Output:</strong> &quot;kiran&quot;
39-
4034
<strong>Explanation:</strong> &quot;kiran&quot; has prefixes &quot;kira&quot;, &quot;kir&quot;, &quot;ki&quot;, and &quot;k&quot;, and all of them appear in words.
41-
4235
</pre>
4336

4437
<p><strong class="example">Example 2:</strong></p>
4538

4639
<pre>
47-
4840
<strong>Input:</strong> words = [&quot;a&quot;, &quot;banana&quot;, &quot;app&quot;, &quot;appl&quot;, &quot;ap&quot;, &quot;apply&quot;, &quot;apple&quot;]
49-
5041
<strong>Output:</strong> &quot;apple&quot;
51-
5242
<strong>Explanation:</strong> Both &quot;apple&quot; and &quot;apply&quot; have all their prefixes in words.
53-
5443
However, &quot;apple&quot; is lexicographically smaller, so we return that.
55-
5644
</pre>
5745

5846
<p><strong class="example">Example 3:</strong></p>
5947

6048
<pre>
61-
6249
<strong>Input:</strong> words = [&quot;abc&quot;, &quot;bc&quot;, &quot;ab&quot;, &quot;qwe&quot;]
63-
6450
<strong>Output:</strong> &quot;&quot;
65-
6651
</pre>
6752

6853
<p>&nbsp;</p>
69-
7054
<p><strong>Constraints:</strong></p>
7155

7256
<ul>
73-
74-
<li><code>1 &lt;= words.length &lt;= 10<sup>5</sup></code></li>
75-
76-
<li><code>1 &lt;= words[i].length &lt;= 10<sup>5</sup></code></li>
77-
78-
<li><code>1 &lt;= sum(words[i].length) &lt;= 10<sup>5</sup></code></li>
79-
57+
<li><code>1 &lt;= words.length &lt;= 10<sup>5</sup></code></li>
58+
<li><code>1 &lt;= words[i].length &lt;= 10<sup>5</sup></code></li>
59+
<li><code>1 &lt;= sum(words[i].length) &lt;= 10<sup>5</sup></code></li>
60+
<li><code>words[i]</code> consists only of lowercase English letters.</li>
8061
</ul>
8162

8263
<!-- description:end -->

‎solution/2000-2099/2073.Time Needed to Buy Tickets/README.md

+31-14
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,40 @@ tags:
3232

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

35-
<pre><strong>输入:</strong>tickets = [2,3,2], k = 2
36-
<strong>输出:</strong>6
37-
<strong>解释:</strong>
38-
- 第一轮,队伍中的每个人都买到一张票,队伍变为 [1, 2, 1] 。
39-
- 第二轮,队伍中的每个都又都买到一张票,队伍变为 [0, 1, 0] 。
40-
位置 2 的人成功买到 2 张票,用掉 3 + 3 = 6 秒。
41-
</pre>
35+
<div class="example-block"><strong>输入:</strong>tickets = [2,3,2], k = 2</div>
36+
37+
<div class="example-block"><strong>输出:</strong>6</div>
38+
39+
<div class="example-block"><strong>解释:</strong></div>
40+
41+
<div class="example-block">&nbsp;</div>
42+
43+
<ul>
44+
<li class="example-block">队伍一开始为 [2,3,2],第 k 个人以下划线标识。</li>
45+
<li class="example-block">在最前面的人买完票后,队伍在第 1 秒变成 [3,<u>2</u>,1]。</li>
46+
<li class="example-block">继续这个过程,队伍在第 2 秒变为[<u>2</u>,1,2]。</li>
47+
<li class="example-block">继续这个过程,队伍在第 3 秒变为[1,2,<u>1</u>]。</li>
48+
<li class="example-block">继续这个过程,队伍在第 4 秒变为[2,<u>1</u>]。</li>
49+
<li class="example-block">继续这个过程,队伍在第 5 秒变为[<u>1</u>,1]。</li>
50+
<li class="example-block">继续这个过程,队伍在第 6 秒变为[1]。第 k 个人完成买票,所以返回 6。</li>
51+
</ul>
52+
53+
<div class="example-block">&nbsp;</div>
4254

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

45-
<pre><strong>输入:</strong>tickets = [5,1,1,1], k = 0
46-
<strong>输出:</strong>8
47-
<strong>解释:</strong>
48-
- 第一轮,队伍中的每个人都买到一张票,队伍变为 [4, 0, 0, 0] 。
49-
- 接下来的 4 轮,只有位置 0 的人在买票。
50-
位置 0 的人成功买到 5 张票,用掉 4 + 1 + 1 + 1 + 1 = 8 秒。
51-
</pre>
57+
<div class="example-block"><strong>输入:</strong>tickets = [5,1,1,1], k = 0</div>
58+
59+
<div class="example-block"><strong>输出:</strong>8</div>
60+
61+
<div class="example-block"><strong>解释:</strong></div>
62+
63+
<ul>
64+
<li class="example-block">队伍一开始为 [<u>5</u>,1,1,1],第 k 个人以下划线标识。</li>
65+
<li class="example-block">在最前面的人买完票后,队伍在第 1 秒变成 [1,1,1,<u>4</u>]。</li>
66+
<li class="example-block">继续这个过程 3 秒,队伍在第 4&nbsp;秒变为[<u>4</u>]。</li>
67+
<li class="example-block">继续这个过程 4 秒,队伍在第 8&nbsp;秒变为[]。第 k 个人完成买票,所以返回 8。</li>
68+
</ul>
5269

5370
<p>&nbsp;</p>
5471

‎solution/2000-2099/2073.Time Needed to Buy Tickets/README_EN.md

+32-17
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,45 @@ tags:
2626

2727
<p>Each person takes <strong>exactly 1 second</strong> to buy a ticket. A person can only buy <strong>1 ticket at a time</strong> and has to go back to <strong>the end</strong> of the line (which happens <strong>instantaneously</strong>) in order to buy more tickets. If a person does not have any tickets left to buy, the person will <strong>leave </strong>the line.</p>
2828

29-
<p>Return <em>the <strong>time taken</strong> for the person at position </em><code>k</code><em>&nbsp;</em><strong><em>(0-indexed)</em>&nbsp;</strong><em>to finish buying tickets</em>.</p>
29+
<p>Return the <strong>time taken</strong> for the person <strong>initially</strong> at position <strong>k</strong><strong> </strong>(0-indexed) to finish buying tickets.</p>
3030

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

34-
<pre>
35-
<strong>Input:</strong> tickets = [2,3,2], k = 2
36-
<strong>Output:</strong> 6
37-
<strong>Explanation:</strong>
38-
- In the first pass, everyone in the line buys a ticket and the line becomes [1, 2, 1].
39-
- In the second pass, everyone in the line buys a ticket and the line becomes [0, 1, 0].
40-
The person at&nbsp;position 2 has successfully bought 2 tickets and it took 3 + 3 = 6 seconds.
41-
</pre>
34+
<div class="example-block">
35+
<p><strong>Input:</strong> <span class="example-io">tickets = [2,3,2], k = 2</span></p>
36+
37+
<p><strong>Output:</strong> <span class="example-io">6</span></p>
38+
39+
<p><strong>Explanation:</strong></p>
40+
41+
<ul>
42+
<li>The queue starts as [2,3,<u>2</u>], where the kth person is underlined.</li>
43+
<li>After the person at the front has bought a ticket, the queue becomes [3,<u>2</u>,1] at 1 second.</li>
44+
<li>Continuing this process, the queue becomes [<u>2</u>,1,2] at 2 seconds.</li>
45+
<li>Continuing this process, the queue becomes [1,2,<u>1</u>] at 3 seconds.</li>
46+
<li>Continuing this process, the queue becomes [2,<u>1</u>] at 4 seconds. Note: the person at the front left the queue.</li>
47+
<li>Continuing this process, the queue becomes [<u>1</u>,1] at 5 seconds.</li>
48+
<li>Continuing this process, the queue becomes [1] at 6 seconds. The kth person has bought all their tickets, so return 6.</li>
49+
</ul>
50+
</div>
4251

4352
<p><strong class="example">Example 2:</strong></p>
4453

45-
<pre>
46-
<strong>Input:</strong> tickets = [5,1,1,1], k = 0
47-
<strong>Output:</strong> 8
48-
<strong>Explanation:</strong>
49-
- In the first pass, everyone in the line buys a ticket and the line becomes [4, 0, 0, 0].
50-
- In the next 4 passes, only the person in position 0 is buying tickets.
51-
The person at&nbsp;position 0 has successfully bought 5 tickets and it took 4 + 1 + 1 + 1 + 1 = 8 seconds.
52-
</pre>
54+
<div class="example-block">
55+
<p><strong>Input:</strong> <span class="example-io">tickets = [5,1,1,1], k = 0</span></p>
56+
57+
<p><strong>Output:</strong> <span class="example-io">8</span></p>
58+
59+
<p><strong>Explanation:</strong></p>
60+
61+
<ul>
62+
<li>The queue starts as [<u>5</u>,1,1,1], where the kth person is underlined.</li>
63+
<li>After the person at the front has bought a ticket, the queue becomes [1,1,1,<u>4</u>] at 1 second.</li>
64+
<li>Continuing this process for 3 seconds, the queue becomes [<u>4]</u> at 4 seconds.</li>
65+
<li>Continuing this process for 4 seconds, the queue becomes [] at 8 seconds. The kth person has bought all their tickets, so return 8.</li>
66+
</ul>
67+
</div>
5368

5469
<p>&nbsp;</p>
5570
<p><strong>Constraints:</strong></p>

‎solution/2300-2399/2332.The Latest Time to Catch a Bus/README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ tags:
2525

2626
<p>给你一个整数&nbsp;<code>capacity</code>&nbsp;,表示每辆公交车&nbsp;<strong>最多</strong>&nbsp;能容纳的乘客数目。</p>
2727

28-
<p>每位乘客都会搭乘下一辆有座位的公交车。如果你在 <code>y</code>&nbsp;时刻到达,公交在&nbsp;<code>x</code>&nbsp;时刻出发,满足&nbsp;<code>y &lt;= x</code>&nbsp;&nbsp;且公交没有满,那么你可以搭乘这一辆公交。<strong>最早</strong>&nbsp;到达的乘客优先上车。</p>
28+
<p>每位乘客都会排队搭乘下一辆有座位的公交车。如果你在 <code>y</code>&nbsp;时刻到达,公交在&nbsp;<code>x</code>&nbsp;时刻出发,满足&nbsp;<code>y &lt;= x</code>&nbsp;&nbsp;且公交没有满,那么你可以搭乘这一辆公交。<strong>最早</strong>&nbsp;到达的乘客优先上车。</p>
2929

3030
<p>返回你可以搭乘公交车的最晚到达公交站时间。你 <strong>不能</strong>&nbsp;跟别的乘客同时刻到达。</p>
3131

@@ -35,7 +35,8 @@ tags:
3535

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

38-
<pre><b>输入:</b>buses = [10,20], passengers = [2,17,18,19], capacity = 2
38+
<pre>
39+
<b>输入:</b>buses = [10,20], passengers = [2,17,18,19], capacity = 2
3940
<b>输出:</b>16
4041
<strong>解释:</strong>
4142
第 1 辆公交车载着第 1 位乘客。
@@ -44,7 +45,8 @@ tags:
4445

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

47-
<pre><b>输入:</b>buses = [20,30,10], passengers = [19,13,26,4,25,11,21], capacity = 2
48+
<pre>
49+
<b>输入:</b>buses = [20,30,10], passengers = [19,13,26,4,25,11,21], capacity = 2
4850
<b>输出:</b>20
4951
<b>解释:</b>
5052
第 1 辆公交车载着第 4 位乘客。

0 commit comments

Comments
 (0)
Please sign in to comment.