Skip to content

Commit 4fdaa4c

Browse files
authored
feat: add biweekly contest 137 (#3430)
1 parent 584cf2d commit 4fdaa4c

File tree

34 files changed

+1477
-43
lines changed

34 files changed

+1477
-43
lines changed

solution/0600-0699/0624.Maximum Distance in Arrays/README.md

+25-13
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,48 @@ tags:
99

1010
<!-- problem:start -->
1111

12-
# [624. 数组列表中的最大距离 🔒](https://leetcode.cn/problems/maximum-distance-in-arrays)
12+
# [624. 数组列表中的最大距离](https://leetcode.cn/problems/maximum-distance-in-arrays)
1313

1414
[English Version](/solution/0600-0699/0624.Maximum%20Distance%20in%20Arrays/README_EN.md)
1515

1616
## 题目描述
1717

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

20-
<p>给定&nbsp;<code>m</code>&nbsp;个数组,每个数组都已经按照升序排好序了。现在你需要从两个不同的数组中选择两个整数(每个数组选一个)并且计算它们的距离。两个整数&nbsp;<code>a</code>&nbsp;&nbsp;<code>b</code>&nbsp;之间的距离定义为它们差的绝对值&nbsp;<code>|a-b|</code>&nbsp;。你的任务就是去找到最大距离</p>
20+
<p>给定&nbsp;<code>m</code>&nbsp;个数组,每个数组都已经按照升序排好序了。</p>
21+
22+
<p>现在你需要从两个不同的数组中选择两个整数(每个数组选一个)并且计算它们的距离。两个整数&nbsp;<code>a</code>&nbsp;&nbsp;<code>b</code>&nbsp;之间的距离定义为它们差的绝对值&nbsp;<code>|a-b|</code>&nbsp;。</p>
23+
24+
<p>返回最大距离。</p>
2125

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

24-
<pre><strong>输入:</strong>
25-
[[1,2,3],
26-
[4,5],
27-
[1,2,3]]
28-
<strong>输出:</strong> 4
28+
<pre>
29+
<strong>输入:</strong>[[1,2,3],[4,5],[1,2,3]]
30+
<strong>输出:</strong>4
2931
<strong>解释:</strong>
3032
一种得到答案 4 的方法是从第一个数组或者第三个数组中选择 1,同时从第二个数组中选择 5 。
3133
</pre>
3234

35+
<p><strong class="example">示例 2:</strong></p>
36+
37+
<pre>
38+
<strong>输入:</strong>arrays = [[1],[1]]
39+
<b>输出:</b>0
40+
</pre>
41+
3342
<p>&nbsp;</p>
3443

35-
<p><strong>注意:</strong></p>
44+
<p><strong>提示:</strong></p>
3645

37-
<ol>
38-
<li>每个给定数组至少会有 1 个数字。列表中至少有两个非空数组。</li>
39-
<li><strong>所有</strong>&nbsp;<code>m</code>&nbsp;个数组中的数字总数目在范围 [2, 10000] 内。</li>
40-
<li><code>m</code>&nbsp;个数组中所有整数的范围在 [-10000, 10000] 内。</li>
41-
</ol>
46+
<ul>
47+
<li><code>m == arrays.length</code></li>
48+
<li><code>2 &lt;= m &lt;= 10<sup>5</sup></code></li>
49+
<li><code>1 &lt;= arrays[i].length &lt;= 500</code></li>
50+
<li><code>-10<sup>4</sup> &lt;= arrays[i][j] &lt;= 10<sup>4</sup></code></li>
51+
<li><code>arrays[i]</code>&nbsp;以&nbsp;<strong>升序</strong>&nbsp;排序。</li>
52+
<li>所有数组中最多有&nbsp;<code>10<sup>5</sup></code> 个整数。</li>
53+
</ul>
4254

4355
<p>&nbsp;</p>
4456

solution/0600-0699/0624.Maximum Distance in Arrays/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tags:
99

1010
<!-- problem:start -->
1111

12-
# [624. Maximum Distance in Arrays 🔒](https://leetcode.com/problems/maximum-distance-in-arrays)
12+
# [624. Maximum Distance in Arrays](https://leetcode.com/problems/maximum-distance-in-arrays)
1313

1414
[中文文档](/solution/0600-0699/0624.Maximum%20Distance%20in%20Arrays/README.md)
1515

solution/0800-0899/0860.Lemonade Change/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tags:
2929
<pre>
3030
<strong>Input:</strong> bills = [5,5,5,10,20]
3131
<strong>Output:</strong> true
32-
<strong>Explanation:</strong>
32+
<strong>Explanation:</strong>
3333
From the first 3 customers, we collect three $5 bills in order.
3434
From the fourth customer, we collect a $10 bill and give back a $5.
3535
From the fifth customer, we give a $10 bill and a $5 bill.
@@ -41,7 +41,7 @@ Since all customers got correct change, we output true.
4141
<pre>
4242
<strong>Input:</strong> bills = [5,5,10,10,20]
4343
<strong>Output:</strong> false
44-
<strong>Explanation:</strong>
44+
<strong>Explanation:</strong>
4545
From the first two customers in order, we collect two $5 bills.
4646
For the next two customers in order, we collect a $10 bill and give back a $5 bill.
4747
For the last customer, we can not give the change of $15 back because we only have two $10 bills.

solution/1400-1499/1418.Display Table of Food Orders in a Restaurant/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ tags:
3333
<p><strong>示例 1:</strong></p>
3434

3535
<pre><strong>输入:</strong>orders = [[&quot;David&quot;,&quot;3&quot;,&quot;Ceviche&quot;],[&quot;Corina&quot;,&quot;10&quot;,&quot;Beef Burrito&quot;],[&quot;David&quot;,&quot;3&quot;,&quot;Fried Chicken&quot;],[&quot;Carla&quot;,&quot;5&quot;,&quot;Water&quot;],[&quot;Carla&quot;,&quot;5&quot;,&quot;Ceviche&quot;],[&quot;Rous&quot;,&quot;3&quot;,&quot;Ceviche&quot;]]
36-
<strong>输出:</strong>[[&quot;Table&quot;,&quot;Beef Burrito&quot;,&quot;Ceviche&quot;,&quot;Fried Chicken&quot;,&quot;Water&quot;],[&quot;3&quot;,&quot;0&quot;,&quot;2&quot;,&quot;1&quot;,&quot;0&quot;],[&quot;5&quot;,&quot;0&quot;,&quot;1&quot;,&quot;0&quot;,&quot;1&quot;],[&quot;10&quot;,&quot;1&quot;,&quot;0&quot;,&quot;0&quot;,&quot;0&quot;]]
36+
<strong>输出:</strong>[[&quot;Table&quot;,&quot;Beef Burrito&quot;,&quot;Ceviche&quot;,&quot;Fried Chicken&quot;,&quot;Water&quot;],[&quot;3&quot;,&quot;0&quot;,&quot;2&quot;,&quot;1&quot;,&quot;0&quot;],[&quot;5&quot;,&quot;0&quot;,&quot;1&quot;,&quot;0&quot;,&quot;1&quot;],[&quot;10&quot;,&quot;1&quot;,&quot;0&quot;,&quot;0&quot;,&quot;0&quot;]]
3737
<strong>解释:
3838
</strong>点菜展示表如下所示:
3939
<strong>Table,Beef Burrito,Ceviche,Fried Chicken,Water</strong>
@@ -42,13 +42,13 @@ tags:
4242
10 ,1 ,0 ,0 ,0
4343
对于餐桌 3:David 点了 &quot;Ceviche&quot;&quot;Fried Chicken&quot;,而 Rous 点了 &quot;Ceviche&quot;
4444
而餐桌 5:Carla 点了 &quot;Water&quot;&quot;Ceviche&quot;
45-
餐桌 10:Corina 点了 &quot;Beef Burrito&quot;
45+
餐桌 10:Corina 点了 &quot;Beef Burrito&quot;
4646
</pre>
4747

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

5050
<pre><strong>输入:</strong>orders = [[&quot;James&quot;,&quot;12&quot;,&quot;Fried Chicken&quot;],[&quot;Ratesh&quot;,&quot;12&quot;,&quot;Fried Chicken&quot;],[&quot;Amadeus&quot;,&quot;12&quot;,&quot;Fried Chicken&quot;],[&quot;Adam&quot;,&quot;1&quot;,&quot;Canadian Waffles&quot;],[&quot;Brianna&quot;,&quot;1&quot;,&quot;Canadian Waffles&quot;]]
51-
<strong>输出:</strong>[[&quot;Table&quot;,&quot;Canadian Waffles&quot;,&quot;Fried Chicken&quot;],[&quot;1&quot;,&quot;2&quot;,&quot;0&quot;],[&quot;12&quot;,&quot;0&quot;,&quot;3&quot;]]
51+
<strong>输出:</strong>[[&quot;Table&quot;,&quot;Canadian Waffles&quot;,&quot;Fried Chicken&quot;],[&quot;1&quot;,&quot;2&quot;,&quot;0&quot;],[&quot;12&quot;,&quot;0&quot;,&quot;3&quot;]]
5252
<strong>解释:</strong>
5353
对于餐桌 1:Adam 和 Brianna 都点了 &quot;Canadian Waffles&quot;
5454
而餐桌 12:James, Ratesh 和 Amadeus 都点了 &quot;Fried Chicken&quot;

solution/1400-1499/1418.Display Table of Food Orders in a Restaurant/README_EN.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ tags:
3434

3535
<strong>Input:</strong> orders = [[&quot;David&quot;,&quot;3&quot;,&quot;Ceviche&quot;],[&quot;Corina&quot;,&quot;10&quot;,&quot;Beef Burrito&quot;],[&quot;David&quot;,&quot;3&quot;,&quot;Fried Chicken&quot;],[&quot;Carla&quot;,&quot;5&quot;,&quot;Water&quot;],[&quot;Carla&quot;,&quot;5&quot;,&quot;Ceviche&quot;],[&quot;Rous&quot;,&quot;3&quot;,&quot;Ceviche&quot;]]
3636

37-
<strong>Output:</strong> [[&quot;Table&quot;,&quot;Beef Burrito&quot;,&quot;Ceviche&quot;,&quot;Fried Chicken&quot;,&quot;Water&quot;],[&quot;3&quot;,&quot;0&quot;,&quot;2&quot;,&quot;1&quot;,&quot;0&quot;],[&quot;5&quot;,&quot;0&quot;,&quot;1&quot;,&quot;0&quot;,&quot;1&quot;],[&quot;10&quot;,&quot;1&quot;,&quot;0&quot;,&quot;0&quot;,&quot;0&quot;]]
37+
<strong>Output:</strong> [[&quot;Table&quot;,&quot;Beef Burrito&quot;,&quot;Ceviche&quot;,&quot;Fried Chicken&quot;,&quot;Water&quot;],[&quot;3&quot;,&quot;0&quot;,&quot;2&quot;,&quot;1&quot;,&quot;0&quot;],[&quot;5&quot;,&quot;0&quot;,&quot;1&quot;,&quot;0&quot;,&quot;1&quot;],[&quot;10&quot;,&quot;1&quot;,&quot;0&quot;,&quot;0&quot;,&quot;0&quot;]]
3838

3939
<strong>Explanation:
4040

@@ -52,7 +52,7 @@ For the table 3: David orders &quot;Ceviche&quot; and &quot;Fried Chicken&quot;,
5252

5353
For the table 5: Carla orders &quot;Water&quot; and &quot;Ceviche&quot;.
5454

55-
For the table 10: Corina orders &quot;Beef Burrito&quot;.
55+
For the table 10: Corina orders &quot;Beef Burrito&quot;.
5656

5757
</pre>
5858

@@ -62,9 +62,9 @@ For the table 10: Corina orders &quot;Beef Burrito&quot;.
6262

6363
<strong>Input:</strong> orders = [[&quot;James&quot;,&quot;12&quot;,&quot;Fried Chicken&quot;],[&quot;Ratesh&quot;,&quot;12&quot;,&quot;Fried Chicken&quot;],[&quot;Amadeus&quot;,&quot;12&quot;,&quot;Fried Chicken&quot;],[&quot;Adam&quot;,&quot;1&quot;,&quot;Canadian Waffles&quot;],[&quot;Brianna&quot;,&quot;1&quot;,&quot;Canadian Waffles&quot;]]
6464

65-
<strong>Output:</strong> [[&quot;Table&quot;,&quot;Canadian Waffles&quot;,&quot;Fried Chicken&quot;],[&quot;1&quot;,&quot;2&quot;,&quot;0&quot;],[&quot;12&quot;,&quot;0&quot;,&quot;3&quot;]]
65+
<strong>Output:</strong> [[&quot;Table&quot;,&quot;Canadian Waffles&quot;,&quot;Fried Chicken&quot;],[&quot;1&quot;,&quot;2&quot;,&quot;0&quot;],[&quot;12&quot;,&quot;0&quot;,&quot;3&quot;]]
6666

67-
<strong>Explanation:</strong>
67+
<strong>Explanation:</strong>
6868

6969
For the table 1: Adam and Brianna order &quot;Canadian Waffles&quot;.
7070

solution/1400-1499/1422.Maximum Score After Splitting a String/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ tags:
2828
<p><strong>示例 1:</strong></p>
2929

3030
<pre><strong>输入:</strong>s = &quot;011101&quot;
31-
<strong>输出:</strong>5
31+
<strong>输出:</strong>5
3232
<strong>解释:</strong>
3333
将字符串 s 划分为两个非空子字符串的可行方案有:
34-
左子字符串 = &quot;0&quot; 且 右子字符串 = &quot;11101&quot;,得分 = 1 + 4 = 5
35-
左子字符串 = &quot;01&quot; 且 右子字符串 = &quot;1101&quot;,得分 = 1 + 3 = 4
36-
左子字符串 = &quot;011&quot; 且 右子字符串 = &quot;101&quot;,得分 = 1 + 2 = 3
37-
左子字符串 = &quot;0111&quot; 且 右子字符串 = &quot;01&quot;,得分 = 1 + 1 = 2
34+
左子字符串 = &quot;0&quot; 且 右子字符串 = &quot;11101&quot;,得分 = 1 + 4 = 5
35+
左子字符串 = &quot;01&quot; 且 右子字符串 = &quot;1101&quot;,得分 = 1 + 3 = 4
36+
左子字符串 = &quot;011&quot; 且 右子字符串 = &quot;101&quot;,得分 = 1 + 2 = 3
37+
左子字符串 = &quot;0111&quot; 且 右子字符串 = &quot;01&quot;,得分 = 1 + 1 = 2
3838
左子字符串 = &quot;01110&quot; 且 右子字符串 = &quot;1&quot;,得分 = 2 + 1 = 3
3939
</pre>
4040

solution/1400-1499/1422.Maximum Score After Splitting a String/README_EN.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ tags:
2828

2929
<pre>
3030
<strong>Input:</strong> s = &quot;011101&quot;
31-
<strong>Output:</strong> 5
32-
<strong>Explanation:</strong>
31+
<strong>Output:</strong> 5
32+
<strong>Explanation:</strong>
3333
All possible ways of splitting s into two non-empty substrings are:
34-
left = &quot;0&quot; and right = &quot;11101&quot;, score = 1 + 4 = 5
35-
left = &quot;01&quot; and right = &quot;1101&quot;, score = 1 + 3 = 4
36-
left = &quot;011&quot; and right = &quot;101&quot;, score = 1 + 2 = 3
37-
left = &quot;0111&quot; and right = &quot;01&quot;, score = 1 + 1 = 2
34+
left = &quot;0&quot; and right = &quot;11101&quot;, score = 1 + 4 = 5
35+
left = &quot;01&quot; and right = &quot;1101&quot;, score = 1 + 3 = 4
36+
left = &quot;011&quot; and right = &quot;101&quot;, score = 1 + 2 = 3
37+
left = &quot;0111&quot; and right = &quot;01&quot;, score = 1 + 1 = 2
3838
left = &quot;01110&quot; and right = &quot;1&quot;, score = 2 + 1 = 3
3939
</pre>
4040

solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ function getDirections(root: TreeNode | null, startValue: number, destValue: num
314314
const left = lca(node.left, p, q);
315315
const right = lca(node.right, p, q);
316316

317-
return left && right ? node : (left ?? right);
317+
return left && right ? node : left ?? right;
318318
};
319319

320320
const dfs = (node: TreeNode | null, x: number, path: string[]): boolean => {
@@ -370,7 +370,7 @@ var getDirections = function (root, startValue, destValue) {
370370
const left = lca(node.left, p, q);
371371
const right = lca(node.right, p, q);
372372

373-
return left && right ? node : (left ?? right);
373+
return left && right ? node : left ?? right;
374374
};
375375

376376
const dfs = (node, x, path) => {

solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ function getDirections(root: TreeNode | null, startValue: number, destValue: num
310310
const left = lca(node.left, p, q);
311311
const right = lca(node.right, p, q);
312312

313-
return left && right ? node : (left ?? right);
313+
return left && right ? node : left ?? right;
314314
};
315315

316316
const dfs = (node: TreeNode | null, x: number, path: string[]): boolean => {
@@ -366,7 +366,7 @@ var getDirections = function (root, startValue, destValue) {
366366
const left = lca(node.left, p, q);
367367
const right = lca(node.right, p, q);
368368

369-
return left && right ? node : (left ?? right);
369+
return left && right ? node : left ?? right;
370370
};
371371

372372
const dfs = (node, x, path) => {

solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/Solution.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var getDirections = function (root, startValue, destValue) {
2020
const left = lca(node.left, p, q);
2121
const right = lca(node.right, p, q);
2222

23-
return left && right ? node : (left ?? right);
23+
return left && right ? node : left ?? right;
2424
};
2525

2626
const dfs = (node, x, path) => {

solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/Solution.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function getDirections(root: TreeNode | null, startValue: number, destValue: num
2020
const left = lca(node.left, p, q);
2121
const right = lca(node.right, p, q);
2222

23-
return left && right ? node : (left ?? right);
23+
return left && right ? node : left ?? right;
2424
};
2525

2626
const dfs = (node: TreeNode | null, x: number, path: string[]): boolean => {

0 commit comments

Comments
 (0)