Skip to content

Commit 69871d2

Browse files
authored
Merge pull request #415 from LetMeFly666/3067
添加问题“3067.在带权树网络中统计可连接服务器对数目”的代码和题解
2 parents 59413f5 + 50c924d commit 69871d2

File tree

374 files changed

+11368
-2814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

374 files changed

+11368
-2814
lines changed

AllProblems/1011.在 D 天内送达包裹的能力.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tags: [题解, LeetCode, 中等, 数组, 二分查找]
1616

1717
<p>&nbsp;</p>
1818

19-
<p><strong>示例 1:</strong></p>
19+
<p><strong class="example">示例 1:</strong></p>
2020

2121
<pre>
2222
<strong>输入:</strong>weights = [1,2,3,4,5,6,7,8,9,10], days = 5
@@ -32,7 +32,7 @@ tags: [题解, LeetCode, 中等, 数组, 二分查找]
3232
请注意,货物必须按照给定的顺序装运,因此使用载重能力为 14 的船舶并将包装分成 (2, 3, 4, 5), (1, 6, 7), (8), (9), (10) 是不允许的。
3333
</pre>
3434

35-
<p><strong>示例 2:</strong></p>
35+
<p><strong class="example">示例 2:</strong></p>
3636

3737
<pre>
3838
<strong>输入:</strong>weights = [3,2,2,4,1,4], days = 3
@@ -44,7 +44,7 @@ tags: [题解, LeetCode, 中等, 数组, 二分查找]
4444
第 3 天:1, 4
4545
</pre>
4646

47-
<p><strong>示例 3:</strong></p>
47+
<p><strong class="example">示例 3:</strong></p>
4848

4949
<pre>
5050
<strong>输入:</strong>weights = [1,2,3,1,1], days = 4

AllProblems/1018.可被 5 整除的二进制前缀.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 1018.可被 5 整除的二进制前缀
33
date: 2022-06-02 20-02-39
4-
tags: [题解, LeetCode, 简单, 数组]
4+
tags: [题解, LeetCode, 简单, 位运算, 数组]
55
---
66

77
# 【LetMeFly】1018.可被 5 整除的二进制前缀

AllProblems/1023.驼峰式匹配.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 1023.驼峰式匹配
33
date: 2022-06-02 20-02-41
4-
tags: [题解, LeetCode, 中等, 字典树, 双指针, 字符串, 字符串匹配]
4+
tags: [题解, LeetCode, 中等, 字典树, 数组, 双指针, 字符串, 字符串匹配]
55
---
66

77
# 【LetMeFly】1023.驼峰式匹配
@@ -10,7 +10,7 @@ tags: [题解, LeetCode, 中等, 字典树, 双指针, 字符串, 字符串匹
1010

1111
<p>给你一个字符串数组 <code>queries</code>,和一个表示模式的字符串&nbsp;<code>pattern</code>,请你返回一个布尔数组 <code>answer</code> 。只有在待查项&nbsp;<code>queries[i]</code> 与模式串&nbsp;<code>pattern</code> 匹配时,&nbsp;<code>answer[i]</code>&nbsp;才为 <code>true</code>,否则为 <code>false</code>。</p>
1212

13-
<p>如果可以将<strong>小写字母</strong>插入模式串&nbsp;<code>pattern</code>&nbsp;得到待查询项&nbsp;<code>query</code>,那么待查询项与给定模式串匹配。可以在任何位置插入每个字符,也可以不插入字符。</p>
13+
<p>如果可以将<strong>小写字母</strong>插入模式串&nbsp;<code>pattern</code>&nbsp;得到待查询项&nbsp;<code>queries[i]</code>,那么待查询项与给定模式串匹配。可以在任何位置插入每个字符,也可以不插入字符。</p>
1414

1515
<p>&nbsp;</p>
1616

AllProblems/1035.不相交的线.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ tags: [题解, LeetCode, 中等, 数组, 动态规划]
1010

1111
<p>在两条独立的水平线上按给定的顺序写下 <code>nums1</code> 和 <code>nums2</code> 中的整数。</p>
1212

13-
<p>现在,可以绘制一些连接两个数字 <code>nums1[i]</code>&nbsp;和 <code>nums2[j]</code>&nbsp;的直线,这些直线需要同时满足满足:</p>
13+
<p>现在,可以绘制一些连接两个数字 <code>nums1[i]</code>&nbsp;和 <code>nums2[j]</code>&nbsp;的直线,这些直线需要同时满足:</p>
1414

1515
<ul>
1616
<li>&nbsp;<code>nums1[i] == nums2[j]</code></li>

AllProblems/1053.交换一次的先前排列.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tags: [题解, LeetCode, 中等, 贪心, 数组]
88

99
力扣题目链接:[https://leetcode.cn/problems/previous-permutation-with-one-swap/](https://leetcode.cn/problems/previous-permutation-with-one-swap/)
1010

11-
<p>给你一个正整数数组 <code>arr</code>(可能存在重复的元素),请你返回可在&nbsp;<strong>一次交换</strong>(交换两数字 <code>arr[i]</code> 和 <code>arr[j]</code> 的位置)后得到的、按字典序排列小于 <code>arr</code> 的最大排列。</p>
11+
<p>给你一个正整数数组 <code>arr</code>(可能存在重复的元素),请你返回可在&nbsp;<strong>一次交换</strong>(交换两数字 <code>arr[i]</code> 和 <code>arr[j]</code> 的位置)后得到的、按<span data-keyword="lexicographically-smaller-string-alien">字典序</span>排列小于 <code>arr</code> 的最大排列。</p>
1212

1313
<p>如果无法这么操作,就请返回原数组。</p>
1414

AllProblems/1071.字符串的最大公因子.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tags: [题解, LeetCode, 简单, 数学, 字符串]
88

99
力扣题目链接:[https://leetcode.cn/problems/greatest-common-divisor-of-strings/](https://leetcode.cn/problems/greatest-common-divisor-of-strings/)
1010

11-
<p>对于字符串&nbsp;<code>s</code> 和&nbsp;<code>t</code>,只有在&nbsp;<code>s = t + ... + t</code>(<code>t</code> 自身连接 1 次或多次)时,我们才认定&nbsp;“<code>t</code> 能除尽 <code>s</code>”。</p>
11+
<p>对于字符串&nbsp;<code>s</code> 和&nbsp;<code>t</code>,只有在&nbsp;<code>s = t + t + t + ... + t + t</code>(<code>t</code> 自身连接 1 次或多次)时,我们才认定&nbsp;“<code>t</code> 能除尽 <code>s</code>”。</p>
1212

1313
<p>给定两个字符串&nbsp;<code>str1</code>&nbsp;&nbsp;<code>str2</code>&nbsp;。返回 <em>最长字符串&nbsp;<code>x</code>,要求满足&nbsp;<code>x</code> 能除尽 <code>str1</code> 且 <code>x</code> 能除尽 <code>str2</code></em> 。</p>
1414

AllProblems/1074.元素和为目标值的子矩阵数量.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ tags: [题解, LeetCode, 困难, 数组, 哈希表, 矩阵, 前缀和]
88

99
力扣题目链接:[https://leetcode.cn/problems/number-of-submatrices-that-sum-to-target/](https://leetcode.cn/problems/number-of-submatrices-that-sum-to-target/)
1010

11-
<p>给出矩阵 <code>matrix</code> 和目标值 <code>target</code>,返回元素总和等于目标值的非空子矩阵的数量。</p>
11+
<p>给出矩阵&nbsp;<code>matrix</code>&nbsp;和目标值&nbsp;<code>target</code>,返回元素总和等于目标值的非空子矩阵的数量。</p>
1212

13-
<p>子矩阵 <code>x1, y1, x2, y2</code> 是满足 <code>x1 <= x <= x2</code> 且 <code>y1 <= y <= y2</code> 的所有单元 <code>matrix[x][y]</code> 的集合。</p>
13+
<p>子矩阵&nbsp;<code>x1, y1, x2, y2</code>&nbsp;是满足 <code>x1 &lt;= x &lt;= x2</code>&nbsp;&nbsp;<code>y1 &lt;= y &lt;= y2</code>&nbsp;的所有单元&nbsp;<code>matrix[x][y]</code>&nbsp;的集合。</p>
1414

15-
<p>如果 <code>(x1, y1, x2, y2)</code> 和 <code>(x1', y1', x2', y2')</code> 两个子矩阵中部分坐标不同(如:<code>x1 != x1'</code>),那么这两个子矩阵也不同。</p>
15+
<p>如果&nbsp;<code>(x1, y1, x2, y2)</code> 和&nbsp;<code>(x1', y1', x2', y2')</code>&nbsp;两个子矩阵中部分坐标不同(如:<code>x1 != x1'</code>),那么这两个子矩阵也不同。</p>
1616

17-
<p> </p>
17+
<p>&nbsp;</p>
1818

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

@@ -41,15 +41,15 @@ tags: [题解, LeetCode, 困难, 数组, 哈希表, 矩阵, 前缀和]
4141
<strong>输出:</strong>0
4242
</pre>
4343

44-
<p> </p>
44+
<p>&nbsp;</p>
4545

4646
<p><strong><strong>提示:</strong></strong></p>
4747

4848
<ul>
49-
<li><code>1 <= matrix.length <= 100</code></li>
50-
<li><code>1 <= matrix[0].length <= 100</code></li>
51-
<li><code>-1000 <= matrix[i] <= 1000</code></li>
52-
<li><code>-10^8 <= target <= 10^8</code></li>
49+
<li><code>1 &lt;= matrix.length &lt;= 100</code></li>
50+
<li><code>1 &lt;= matrix[0].length &lt;= 100</code></li>
51+
<li><code>-1000 &lt;= matrix[i][j] &lt;= 1000</code></li>
52+
<li><code>-10^8 &lt;= target &lt;= 10^8</code></li>
5353
</ul>
5454

5555

AllProblems/1075.项目员工 I.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ tags: [题解, LeetCode, 简单, 数据库]
1919
+-------------+---------+
2020
主键为 (project_id, employee_id)。
2121
employee_id 是员工表 <code>Employee 表的外键。</code>
22+
这张表的每一行表示 employee_id 的员工正在 project_id 的项目上工作。
2223
</pre>
2324

25+
<p>&nbsp;</p>
26+
2427
<p>员工表&nbsp;<code>Employee</code>:</p>
2528

2629
<pre>
@@ -31,16 +34,23 @@ employee_id 是员工表 <code>Employee 表的外键。</code>
3134
| name | varchar |
3235
| experience_years | int |
3336
+------------------+---------+
34-
主键是 employee_id。
35-
</pre>
37+
主键是 employee_id。数据保证 experience_years 非空。
38+
这张表的每一行包含一个员工的信息。</pre>
3639

3740
<p>&nbsp;</p>
3841

3942
<p>请写一个 SQL&nbsp;语句,查询每一个项目中员工的&nbsp;<strong>平均&nbsp;</strong>工作年限,<strong>精确到小数点后两位</strong>。</p>
4043

41-
<p>查询结果的格式如下:</p>
44+
<p>以 <strong>任意</strong> 顺序返回结果表。</p>
45+
46+
<p>查询结果的格式如下。</p>
47+
48+
<p>&nbsp;</p>
49+
50+
<p><strong>示例 1:</strong></p>
4251

4352
<pre>
53+
<strong>输入:</strong>
4454
Project 表:
4555
+-------------+-------------+
4656
| project_id | employee_id |
@@ -62,14 +72,14 @@ Employee 表:
6272
| 4 | Doe | 2 |
6373
+-------------+--------+------------------+
6474

65-
Result 表:
75+
<strong>输出:</strong>
6676
+-------------+---------------+
6777
| project_id | average_years |
6878
+-------------+---------------+
6979
| 1 | 2.00 |
7080
| 2 | 2.50 |
7181
+-------------+---------------+
72-
第一个项目中,员工的平均工作年限是 (3 + 2 + 1) / 3 = 2.00;第二个项目中,员工的平均工作年限是 (3 + 2) / 2 = 2.50
82+
<strong>解释:</strong>第一个项目中,员工的平均工作年限是 (3 + 2 + 1) / 3 = 2.00;第二个项目中,员工的平均工作年限是 (3 + 2) / 2 = 2.50
7383
</pre>
7484

7585

AllProblems/108.将有序数组转换为二叉搜索树.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ tags: [题解, LeetCode, 简单, 树, 二叉搜索树, 数组, 分治, 二叉树
88

99
力扣题目链接:[https://leetcode.cn/problems/convert-sorted-array-to-binary-search-tree/](https://leetcode.cn/problems/convert-sorted-array-to-binary-search-tree/)
1010

11-
<p>给你一个整数数组 <code>nums</code> ,其中元素已经按 <strong>升序</strong> 排列,请你将其转换为一棵 <strong>高度平衡</strong> 二叉搜索树。</p>
12-
13-
<p><strong>高度平衡 </strong>二叉树是一棵满足「每个节点的左右两个子树的高度差的绝对值不超过 1 」的二叉树。</p>
11+
<p>给你一个整数数组 <code>nums</code> ,其中元素已经按 <strong>升序</strong> 排列,请你将其转换为一棵 <span data-keyword="height-balanced">平衡</span> 二叉搜索树。</p>
1412

1513
<p>&nbsp;</p>
1614

AllProblems/1081.不同字符的最小子序列.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tags: [题解, LeetCode, 中等, 栈, 贪心, 字符串, 单调栈]
88

99
力扣题目链接:[https://leetcode.cn/problems/smallest-subsequence-of-distinct-characters/](https://leetcode.cn/problems/smallest-subsequence-of-distinct-characters/)
1010

11-
<p>返回 <code>s</code> 字典序最小的子序列,该子序列包含 <code>s</code> 的所有不同字符,且只包含一次。</p>
11+
<p>返回 <code>s</code> 字典序最小的<span data-keyword="subsequence-array">子序列</span>,该子序列包含 <code>s</code> 的所有不同字符,且只包含一次。</p>
1212

1313
<p>&nbsp;</p>
1414

0 commit comments

Comments
 (0)