Skip to content

Commit df28fc3

Browse files
committed
feat: add new lc problems
1 parent f46f935 commit df28fc3

File tree

30 files changed

+346
-237
lines changed

30 files changed

+346
-237
lines changed

lcp/LCP 62. 交通枢纽/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
> 解释:如下图所示:
2626
> 地点 `0,1,2` 各有一条通往地点 `3` 的交通专线,
2727
> 且地点 `3` 不存在任何**通往其他地点**的交通专线。
28-
><br><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/lcp/LCP%2062.%20%E4%BA%A4%E9%80%9A%E6%9E%A2%E7%BA%BD/images/1663902572-yOlUCr-image.png" style="width: 200px;" />
28+
> <br><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/lcp/LCP%2062.%20%E4%BA%A4%E9%80%9A%E6%9E%A2%E7%BA%BD/images/1663902572-yOlUCr-image.png" style="width: 200px;" />
2929
3030
**示例 2:**
3131

@@ -34,7 +34,7 @@
3434
> 输出:`-1`
3535
>
3636
> 解释:如下图所示:不存在满足 **交通枢纽** 的地点。
37-
><br><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/lcp/LCP%2062.%20%E4%BA%A4%E9%80%9A%E6%9E%A2%E7%BA%BD/images/1663902595-McsEkY-image.png" style="width: 200px;" />
37+
> <br><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/lcp/LCP%2062.%20%E4%BA%A4%E9%80%9A%E6%9E%A2%E7%BA%BD/images/1663902595-McsEkY-image.png" style="width: 200px;" />
3838
3939
**提示:**
4040

lcp/LCP 70. 沙地治理/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
> 如下图所示,(1,1)和(2,2)相邻,(3,2)和(3,3)相邻;(2,2)和(3,3)不相邻,因为它们没有共用边。
1414
- 若至少有两片绿地与同一片沙地相邻,则这片沙地也会转化为绿地
1515
- 转化为绿地的区域会影响其相邻的沙地
16-
<br><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/lcp/LCP%2070.%20%E6%B2%99%E5%9C%B0%E6%B2%BB%E7%90%86/images/1662692397-VlvErS-image.png" style="width: 300px;" />
16+
<br><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/lcp/LCP%2070.%20%E6%B2%99%E5%9C%B0%E6%B2%BB%E7%90%86/images/1662692397-VlvErS-image.png" style="width: 300px;" />
1717

1818
现要将一片边长为 `size`  的沙地全部转化为绿地,请找到任意一种初始指定 **最少** 数量子区域种植沙柳的方案,并返回所有初始种植沙柳树的绿地坐标。
1919

@@ -25,7 +25,7 @@
2525
> 指定所示的 5 个子区域为绿地。
2626
> 相邻至少两片绿地的 (2,2),(3,2) 和 (3,4) 演变为绿地。
2727
> 相邻两片绿地的 (3,3) 演变为绿地。
28-
><br><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/lcp/LCP%2070.%20%E6%B2%99%E5%9C%B0%E6%B2%BB%E7%90%86/images/1662692503-ncjywh-image.png" style="width: 300px;" />
28+
> <br><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/lcp/LCP%2070.%20%E6%B2%99%E5%9C%B0%E6%B2%BB%E7%90%86/images/1662692503-ncjywh-image.png" style="width: 300px;" />
2929
3030
**示例 2:**
3131

@@ -34,7 +34,7 @@
3434
> 解释:如下图所示:
3535
> 指定所示的 3 个子区域为绿地。
3636
> 相邻三片绿地的 (2,2) 演变为绿地。
37-
><br><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/lcp/LCP%2070.%20%E6%B2%99%E5%9C%B0%E6%B2%BB%E7%90%86/images/1662692507-mgFXRj-image.png" style="width: 300px;" />
37+
> <br><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/lcp/LCP%2070.%20%E6%B2%99%E5%9C%B0%E6%B2%BB%E7%90%86/images/1662692507-mgFXRj-image.png" style="width: 300px;" />
3838
3939
**提示:**
4040

solution/0000-0099/0044.Wildcard Matching/README.md

+32-41
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,53 @@
66

77
<!-- 这里写题目描述 -->
88

9-
<p>给定一个字符串&nbsp;(<code>s</code>) 和一个字符模式&nbsp;(<code>p</code>) ,实现一个支持&nbsp;<code>&#39;?&#39;</code>&nbsp;&nbsp;<code>&#39;*&#39;</code>&nbsp;的通配符匹配。</p>
10-
11-
<pre>&#39;?&#39; 可以匹配任何单个字符。
12-
&#39;*&#39; 可以匹配任意字符串(包括空字符串)。
13-
</pre>
14-
15-
<p>两个字符串<strong>完全匹配</strong>才算匹配成功。</p>
16-
17-
<p><strong>说明:</strong></p>
9+
<div class="title__3Vvk">给你一个输入字符串 (<code>s</code>) 和一个字符模式 (<code>p</code>) ,请你实现一个支持 <code>'?'</code> 和 <code>'*'</code> 匹配规则的通配符匹配:</div>
1810

1911
<ul>
20-
<li><code>s</code>&nbsp;可能为空,且只包含从&nbsp;<code>a-z</code>&nbsp;的小写字母。</li>
21-
<li><code>p</code>&nbsp;可能为空,且只包含从&nbsp;<code>a-z</code>&nbsp;的小写字母,以及字符&nbsp;<code>?</code>&nbsp;和&nbsp;<code>*</code>。</li>
12+
<li class="title__3Vvk"><code>'?'</code> 可以匹配任何单个字符。</li>
13+
<li class="title__3Vvk"><code>'*'</code> 可以匹配任意字符序列(包括空字符序列)。</li>
2214
</ul>
2315

24-
<p><strong>示例&nbsp;1:</strong></p>
16+
<div class="original__bRMd">
17+
<div>
18+
<p>判定匹配成功的充要条件是:字符模式必须能够 <strong>完全匹配</strong> 输入字符串(而不是部分匹配)。</p>
19+
</div>
20+
</div>
21+
&nbsp;
2522

26-
<pre><strong>输入:</strong>
27-
s = &quot;aa&quot;
28-
p = &quot;a&quot;
29-
<strong>输出:</strong> false
30-
<strong>解释:</strong> &quot;a&quot; 无法匹配 &quot;aa&quot; 整个字符串。</pre>
23+
<p><strong class="example">示例 1:</strong></p>
3124

32-
<p><strong>示例&nbsp;2:</strong></p>
33-
34-
<pre><strong>输入:</strong>
35-
s = &quot;aa&quot;
36-
p = &quot;*&quot;
37-
<strong>输出:</strong> true
38-
<strong>解释:</strong>&nbsp;&#39;*&#39; 可以匹配任意字符串。
25+
<pre>
26+
<strong>输入:</strong>s = "aa", p = "a"
27+
<strong>输出:</strong>false
28+
<strong>解释:</strong>"a" 无法匹配 "aa" 整个字符串。
3929
</pre>
4030

41-
<p><strong>示例&nbsp;3:</strong></p>
31+
<p><strong class="example">示例 2:</strong></p>
4232

43-
<pre><strong>输入:</strong>
44-
s = &quot;cb&quot;
45-
p = &quot;?a&quot;
46-
<strong>输出:</strong> false
47-
<strong>解释:</strong>&nbsp;&#39;?&#39; 可以匹配 &#39;c&#39;, 但第二个 &#39;a&#39; 无法匹配 &#39;b&#39;
33+
<pre>
34+
<strong>输入:</strong>s = "aa", p = "*"
35+
<strong>输出:</strong>true
36+
<strong>解释:</strong>'*' 可以匹配任意字符串。
4837
</pre>
4938

50-
<p><strong>示例&nbsp;4:</strong></p>
39+
<p><strong class="example">示例 3:</strong></p>
5140

52-
<pre><strong>输入:</strong>
53-
s = &quot;adceb&quot;
54-
p = &quot;*a*b&quot;
55-
<strong>输出:</strong> true
56-
<strong>解释:</strong>&nbsp;第一个 &#39;*&#39; 可以匹配空字符串, 第二个 &#39;*&#39; 可以匹配字符串 &quot;dce&quot;.
41+
<pre>
42+
<strong>输入:</strong>s = "cb", p = "?a"
43+
<strong>输出:</strong>false
44+
<strong>解释:</strong>'?' 可以匹配 'c', 但第二个 'a' 无法匹配 'b'。
5745
</pre>
5846

59-
<p><strong>示例&nbsp;5:</strong></p>
47+
<p>&nbsp;</p>
48+
49+
<p><strong>提示:</strong></p>
6050

61-
<pre><strong>输入:</strong>
62-
s = &quot;acdcb&quot;
63-
p = &quot;a*c?b&quot;
64-
<strong>输出:</strong> false</pre>
51+
<ul>
52+
<li><code>0 &lt;= s.length, p.length &lt;= 2000</code></li>
53+
<li><code>s</code> 仅由小写英文字母组成</li>
54+
<li><code>p</code> 仅由小写英文字母、<code>'?'</code> 或 <code>'*'</code> 组成</li>
55+
</ul>
6556

6657
## 解法
6758

solution/0100-0199/0115.Distinct Subsequences/README.md

+8-10
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,43 @@
66

77
<!-- 这里写题目描述 -->
88

9-
<p>给定一个字符串 <code>s</code><strong> </strong>和一个字符串 <code>t</code> ,计算在 <code>s</code> 的子序列中 <code>t</code> 出现的个数。</p>
10-
11-
<p>字符串的一个 <strong>子序列</strong> 是指,通过删除一些(也可以不删除)字符且不干扰剩余字符相对位置所组成的新字符串。(例如,<code>"ACE"</code> 是 <code>"ABCDE"</code> 的一个子序列,而 <code>"AEC"</code> 不是)</p>
9+
<p>给你两个字符串 <code>s</code><strong> </strong>和 <code>t</code> ,统计并返回在 <code>s</code> 的 <strong>子序列</strong> 中 <code>t</code> 出现的个数。</p>
1210

1311
<p>题目数据保证答案符合 32 位带符号整数范围。</p>
1412

15-
<p> </p>
13+
<p>&nbsp;</p>
1614

17-
<p><strong>示例 1:</strong></p>
15+
<p><strong>示例&nbsp;1:</strong></p>
1816

1917
<pre>
2018
<strong>输入:</strong>s = "rabbbit", t = "rabbit"<code>
2119
<strong>输出</strong></code><strong>:</strong><code>3
2220
</code><strong>解释:</strong>
23-
如下图所示, 有 3 种可以从 s 中得到 <code>"rabbit" 的方案</code>。
21+
如下所示, 有 3 种可以从 s 中得到 <code>"rabbit" 的方案</code>。
2422
<code><strong><u>rabb</u></strong>b<strong><u>it</u></strong></code>
2523
<code><strong><u>ra</u></strong>b<strong><u>bbit</u></strong></code>
2624
<code><strong><u>rab</u></strong>b<strong><u>bit</u></strong></code></pre>
2725

28-
<p><strong>示例 2:</strong></p>
26+
<p><strong>示例&nbsp;2:</strong></p>
2927

3028
<pre>
3129
<strong>输入:</strong>s = "babgbag", t = "bag"
3230
<code><strong>输出</strong></code><strong>:</strong><code>5
3331
</code><strong>解释:</strong>
34-
如下图所示, 有 5 种可以从 s 中得到 <code>"bag" 的方案</code>。
32+
如下所示, 有 5 种可以从 s 中得到 <code>"bag" 的方案</code>。
3533
<code><strong><u>ba</u></strong>b<u><strong>g</strong></u>bag</code>
3634
<code><strong><u>ba</u></strong>bgba<strong><u>g</u></strong></code>
3735
<code><u><strong>b</strong></u>abgb<strong><u>ag</u></strong></code>
3836
<code>ba<u><strong>b</strong></u>gb<u><strong>ag</strong></u></code>
3937
<code>babg<strong><u>bag</u></strong></code>
4038
</pre>
4139

42-
<p> </p>
40+
<p>&nbsp;</p>
4341

4442
<p><strong>提示:</strong></p>
4543

4644
<ul>
47-
<li><code>0 <= s.length, t.length <= 1000</code></li>
45+
<li><code>1 &lt;= s.length, t.length &lt;= 1000</code></li>
4846
<li><code>s</code> 和 <code>t</code> 由英文字母组成</li>
4947
</ul>
5048

solution/0100-0199/0140.Word Break II/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<li><code>1 &lt;= wordDict[i].length &lt;= 10</code></li>
4141
<li><code>s</code> and <code>wordDict[i]</code> consist of only lowercase English letters.</li>
4242
<li>All the strings of <code>wordDict</code> are <strong>unique</strong>.</li>
43+
<li>Input is generated in a way that the length of the answer doesn&#39;t exceed&nbsp;10<sup>5</sup>.</li>
4344
</ul>
4445

4546
## Solutions

solution/0100-0199/0174.Dungeon Game/README.md

+22-60
Original file line numberDiff line numberDiff line change
@@ -6,91 +6,53 @@
66

77
<!-- 这里写题目描述 -->
88

9-
<style>
10-
11-
table.dungeon, .dungeon th, .dungeon td {
12-
9+
<style type="text/css">table.dungeon, .dungeon th, .dungeon td {
1310
border:3px solid black;
14-
1511
}
1612

17-
18-
1913
.dungeon th, .dungeon td {
20-
2114
text-align: center;
22-
2315
height: 70px;
24-
2516
width: 70px;
26-
2717
}
28-
2918
</style>
30-
31-
<p>一些恶魔抓住了公主(<strong>P</strong>)并将她关在了地下城的右下角。地下城是由&nbsp;M x N 个房间组成的二维网格。我们英勇的骑士(<strong>K</strong>)最初被安置在左上角的房间里,他必须穿过地下城并通过对抗恶魔来拯救公主。</p>
19+
<p>恶魔们抓住了公主并将她关在了地下城&nbsp;<code>dungeon</code> 的 <strong>右下角</strong> 。地下城是由 <code>m x n</code> 个房间组成的二维网格。我们英勇的骑士最初被安置在 <strong>左上角</strong> 的房间里,他必须穿过地下城并通过对抗恶魔来拯救公主。</p>
3220

3321
<p>骑士的初始健康点数为一个正整数。如果他的健康点数在某一时刻降至 0 或以下,他会立即死亡。</p>
3422

3523
<p>有些房间由恶魔守卫,因此骑士在进入这些房间时会失去健康点数(若房间里的值为<em>负整数</em>,则表示骑士将损失健康点数);其他房间要么是空的(房间里的值为 <em>0</em>),要么包含增加骑士健康点数的魔法球(若房间里的值为<em>正整数</em>,则表示骑士将增加健康点数)。</p>
3624

37-
<p>为了尽快到达公主,骑士决定每次只向右或向下移动一步。</p>
38-
39-
<p>&nbsp;</p>
40-
41-
<p><strong>编写一个函数来计算确保骑士能够拯救到公主所需的最低初始健康点数。</strong></p>
42-
43-
<p>例如,考虑到如下布局的地下城,如果骑士遵循最佳路径 <code>右 -&gt; 右 -&gt; 下 -&gt; 下</code>,则骑士的初始健康点数至少为 <strong>7</strong>。</p>
25+
<p>为了尽快解救公主,骑士决定每次只 <strong>向右</strong> 或 <strong>向下</strong> 移动一步。</p>
4426

45-
<table class="dungeon">
27+
<p>返回确保骑士能够拯救到公主所需的最低初始健康点数。</p>
4628

47-
<tr>
29+
<p><strong>注意:</strong>任何房间都可能对骑士的健康点数造成威胁,也可能增加骑士的健康点数,包括骑士进入的左上角房间以及公主被监禁的右下角房间。</p>
4830

49-
<td>-2 (K)</td>
50-
51-
<td>-3</td>
52-
53-
<td>3</td>
54-
55-
</tr>
56-
57-
<tr>
58-
59-
<td>-5</td>
60-
61-
<td>-10</td>
62-
63-
<td>1</td>
64-
65-
</tr>
66-
67-
<tr>
68-
69-
<td>10</td>
70-
71-
<td>30</td>
72-
73-
<td>-5 (P)</td>
74-
75-
</tr>
76-
77-
</table>
31+
<p>&nbsp;</p>
7832

79-
<!---2K -3 3
33+
<p><strong class="example">示例 1:</strong></p>
34+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0174.Dungeon%20Game/images/dungeon-grid-1.jpg" style="width: 253px; height: 253px;" />
35+
<pre>
36+
<strong>输入:</strong>dungeon = [[-2,-3,3],[-5,-10,1],[10,30,-5]]
37+
<strong>输出:</strong>7
38+
<strong>解释:</strong>如果骑士遵循最佳路径:右 -&gt; 右 -&gt; 下 -&gt; 下 ,则骑士的初始健康点数至少为 7 。</pre>
8039

81-
-5 -10 1
40+
<p><strong class="example">示例 2:</strong></p>
8241

83-
10 30 5P-->
42+
<pre>
43+
<strong>输入:</strong>dungeon = [[0]]
44+
<strong>输出:</strong>1
45+
</pre>
8446

8547
<p>&nbsp;</p>
8648

87-
<p><strong>说明:</strong></p>
49+
<p><strong>提示:</strong></p>
8850

8951
<ul>
90-
<li>
91-
<p>骑士的健康点数没有上限。</p>
92-
</li>
93-
<li>任何房间都可能对骑士的健康点数造成威胁,也可能增加骑士的健康点数,包括骑士进入的左上角房间以及公主被监禁的右下角房间。</li>
52+
<li><code>m == dungeon.length</code></li>
53+
<li><code>n == dungeon[i].length</code></li>
54+
<li><code>1 &lt;= m, n &lt;= 200</code></li>
55+
<li><code>-1000 &lt;= dungeon[i][j] &lt;= 1000</code></li>
9456
</ul>
9557

9658
## 解法

solution/0200-0299/0225.Implement Stack using Queues/README_EN.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class MyStack {
102102
public MyStack() {
103103

104104
}
105-
105+
106106
public void push(int x) {
107107
q2.offer(x);
108108
while (!q1.isEmpty()) {
@@ -112,15 +112,15 @@ class MyStack {
112112
q1 = q2;
113113
q2 = q;
114114
}
115-
115+
116116
public int pop() {
117117
return q1.poll();
118118
}
119-
119+
120120
public int top() {
121121
return q1.peek();
122122
}
123-
123+
124124
public boolean empty() {
125125
return q1.isEmpty();
126126
}
@@ -144,7 +144,7 @@ public:
144144
MyStack() {
145145

146146
}
147-
147+
148148
void push(int x) {
149149
q2.push(x);
150150
while (!q1.empty()) {
@@ -153,17 +153,17 @@ public:
153153
}
154154
swap(q1, q2);
155155
}
156-
156+
157157
int pop() {
158158
int x = q1.front();
159159
q1.pop();
160160
return x;
161161
}
162-
162+
163163
int top() {
164164
return q1.front();
165165
}
166-
166+
167167
bool empty() {
168168
return q1.empty();
169169
}

0 commit comments

Comments
 (0)