Skip to content

Commit f3a2ec4

Browse files
committed
docs: add new lc problems
1 parent 5033f4e commit f3a2ec4

File tree

29 files changed

+1808
-461
lines changed

29 files changed

+1808
-461
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# [1909. 删除一个元素使数组严格递增](https://leetcode-cn.com/problems/remove-one-element-to-make-the-array-strictly-increasing)
2+
3+
[English Version](/solution/1900-1999/1909.Remove%20One%20Element%20to%20Make%20the%20Array%20Strictly%20Increasing/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code> ,如果 <strong>恰好</strong> 删除 <strong>一个</strong> 元素后,数组 <strong>严格递增</strong> ,那么请你返回 <code>true</code> ,否则返回 <code>false</code> 。如果数组本身已经是严格递增的,请你也返回 <code>true</code> 。</p>
10+
11+
<p>数组 <code>nums</code> 是 <strong>严格递增</strong> 的定义为:对于任意下标的 <code>1 &lt;= i &lt; nums.length</code> 都满足 <code>nums[i - 1] &lt; nums[i]</code> 。</p>
12+
13+
<p> </p>
14+
15+
<p><strong>示例 1:</strong></p>
16+
17+
<pre><b>输入:</b>nums = [1,2,<strong>10</strong>,5,7]
18+
<b>输出:</b>true
19+
<b>解释:</b>从 nums 中删除下标 2 处的 10 ,得到 [1,2,5,7] 。
20+
[1,2,5,7] 是严格递增的,所以返回 true 。
21+
</pre>
22+
23+
<p><strong>示例 2:</strong></p>
24+
25+
<pre><b>输入:</b>nums = [2,3,1,2]
26+
<b>输出:</b>false
27+
<b>解释:</b>
28+
[3,1,2] 是删除下标 0 处元素后得到的结果。
29+
[2,1,2] 是删除下标 1 处元素后得到的结果。
30+
[2,3,2] 是删除下标 2 处元素后得到的结果。
31+
[2,3,1] 是删除下标 3 处元素后得到的结果。
32+
没有任何结果数组是严格递增的,所以返回 false 。</pre>
33+
34+
<p><strong>示例 3:</strong></p>
35+
36+
<pre><b>输入:</b>nums = [1,1,1]
37+
<b>输出:</b>false
38+
<b>解释:</b>删除任意元素后的结果都是 [1,1] 。
39+
[1,1] 不是严格递增的,所以返回 false 。
40+
</pre>
41+
42+
<p><strong>示例 4:</strong></p>
43+
44+
<pre><b>输入:</b>nums = [1,2,3]
45+
<b>输出:</b>true
46+
<b>解释:</b>[1,2,3] 已经是严格递增的,所以返回 true 。
47+
</pre>
48+
49+
<p> </p>
50+
51+
<p><strong>提示:</strong></p>
52+
53+
<ul>
54+
<li><code>2 &lt;= nums.length &lt;= 1000</code></li>
55+
<li><code>1 &lt;= nums[i] &lt;= 1000</code></li>
56+
</ul>
57+
58+
59+
## 解法
60+
61+
<!-- 这里可写通用的实现逻辑 -->
62+
63+
<!-- tabs:start -->
64+
65+
### **Python3**
66+
67+
<!-- 这里可写当前语言的特殊实现逻辑 -->
68+
69+
```python
70+
71+
```
72+
73+
### **Java**
74+
75+
<!-- 这里可写当前语言的特殊实现逻辑 -->
76+
77+
```java
78+
79+
```
80+
81+
### **...**
82+
83+
```
84+
85+
```
86+
87+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# [1909. Remove One Element to Make the Array Strictly Increasing](https://leetcode.com/problems/remove-one-element-to-make-the-array-strictly-increasing)
2+
3+
[中文文档](/solution/1900-1999/1909.Remove%20One%20Element%20to%20Make%20the%20Array%20Strictly%20Increasing/README.md)
4+
5+
## Description
6+
7+
<p>Given a <strong>0-indexed</strong> integer array <code>nums</code>, return <code>true</code> <em>if it can be made <strong>strictly increasing</strong> after removing <strong>exactly one</strong> element, or </em><code>false</code><em> otherwise. If the array is already strictly increasing, return </em><code>true</code>.</p>
8+
9+
<p>The array <code>nums</code> is <strong>strictly increasing</strong> if <code>nums[i - 1] &lt; nums[i]</code> for each index <code>(1 &lt;= i &lt; nums.length).</code></p>
10+
11+
<p>&nbsp;</p>
12+
<p><strong>Example 1:</strong></p>
13+
14+
<pre>
15+
<strong>Input:</strong> nums = [1,2,<u>10</u>,5,7]
16+
<strong>Output:</strong> true
17+
<strong>Explanation:</strong> By removing 10 at index 2 from nums, it becomes [1,2,5,7].
18+
[1,2,5,7] is strictly increasing, so return true.
19+
</pre>
20+
21+
<p><strong>Example 2:</strong></p>
22+
23+
<pre>
24+
<strong>Input:</strong> nums = [2,3,1,2]
25+
<strong>Output:</strong> false
26+
<strong>Explanation:</strong>
27+
[3,1,2] is the result of removing the element at index 0.
28+
[2,1,2] is the result of removing the element at index 1.
29+
[2,3,2] is the result of removing the element at index 2.
30+
[2,3,1] is the result of removing the element at index 3.
31+
No resulting array is strictly increasing, so return false.</pre>
32+
33+
<p><strong>Example 3:</strong></p>
34+
35+
<pre>
36+
<strong>Input:</strong> nums = [1,1,1]
37+
<strong>Output:</strong> false
38+
<strong>Explanation:</strong> The result of removing any element is [1,1].
39+
[1,1] is not strictly increasing, so return false.
40+
</pre>
41+
42+
<p><strong>Example 4:</strong></p>
43+
44+
<pre>
45+
<strong>Input:</strong> nums = [1,2,3]
46+
<strong>Output:</strong> true
47+
<strong>Explanation:</strong> [1,2,3] is already strictly increasing, so return true.
48+
</pre>
49+
50+
<p>&nbsp;</p>
51+
<p><strong>Constraints:</strong></p>
52+
53+
<ul>
54+
<li><code>2 &lt;= nums.length &lt;= 1000</code></li>
55+
<li><code>1 &lt;= nums[i] &lt;= 1000</code></li>
56+
</ul>
57+
58+
59+
## Solutions
60+
61+
<!-- tabs:start -->
62+
63+
### **Python3**
64+
65+
```python
66+
67+
```
68+
69+
### **Java**
70+
71+
```java
72+
73+
```
74+
75+
### **...**
76+
77+
```
78+
79+
```
80+
81+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# [1910. 删除一个字符串中所有出现的给定子字符串](https://leetcode-cn.com/problems/remove-all-occurrences-of-a-substring)
2+
3+
[English Version](/solution/1900-1999/1910.Remove%20All%20Occurrences%20of%20a%20Substring/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>给你两个字符串 <code>s</code> 和 <code>part</code> ,请你对 <code>s</code> 反复执行以下操作直到 <b>所有</b> 子字符串 <code>part</code> 都被删除:</p>
10+
11+
<ul>
12+
<li>找到 <code>s</code> 中 <strong>最左边</strong> 的子字符串 <code>part</code> ,并将它从 <code>s</code> 中删除。</li>
13+
</ul>
14+
15+
<p>请你返回从 <code>s</code> 中删除所有 <code>part</code> 子字符串以后得到的剩余字符串。</p>
16+
17+
<p>一个 <strong>子字符串</strong> 是一个字符串中连续的字符序列。</p>
18+
19+
<p> </p>
20+
21+
<p><strong>示例 1:</strong></p>
22+
23+
<pre><b>输入:</b>s = "daabcbaabcbc", part = "abc"
24+
<b>输出:</b>"dab"
25+
<b>解释:</b>以下操作按顺序执行:
26+
- s = "da<strong>abc</strong>baabcbc" ,删除下标从 2 开始的 "abc" ,得到 s = "dabaabcbc" 。
27+
- s = "daba<strong>abc</strong>bc" ,删除下标从 4 开始的 "abc" ,得到 s = "dababc" 。
28+
- s = "dab<strong>abc</strong>" ,删除下标从 3 开始的 "abc" ,得到 s = "dab" 。
29+
此时 s 中不再含有子字符串 "abc" 。
30+
</pre>
31+
32+
<p><strong>示例 2:</strong></p>
33+
34+
<pre><b>输入:</b>s = "axxxxyyyyb", part = "xy"
35+
<b>输出:</b>"ab"
36+
<b>解释:</b>以下操作按顺序执行:
37+
- s = "axxx<strong>xy</strong>yyyb" ,删除下标从 4 开始的 "xy" ,得到 s = "axxxyyyb" 。
38+
- s = "axx<strong>xy</strong>yyb" ,删除下标从 3 开始的 "xy" ,得到 s = "axxyyb" 。
39+
- s = "ax<strong>xy</strong>yb" ,删除下标从 2 开始的 "xy" ,得到 s = "axyb" 。
40+
- s = "a<strong>xy</strong>b" ,删除下标从 1 开始的 "xy" ,得到 s = "ab" 。
41+
此时 s 中不再含有子字符串 "xy" 。
42+
</pre>
43+
44+
<p> </p>
45+
46+
<p><strong>提示:</strong></p>
47+
48+
<ul>
49+
<li><code>1 &lt;= s.length &lt;= 1000</code></li>
50+
<li><code>1 &lt;= part.length &lt;= 1000</code></li>
51+
<li><code>s</code>​​​​​​ 和 <code>part</code> 只包小写英文字母。</li>
52+
</ul>
53+
54+
55+
## 解法
56+
57+
<!-- 这里可写通用的实现逻辑 -->
58+
59+
<!-- tabs:start -->
60+
61+
### **Python3**
62+
63+
<!-- 这里可写当前语言的特殊实现逻辑 -->
64+
65+
```python
66+
67+
```
68+
69+
### **Java**
70+
71+
<!-- 这里可写当前语言的特殊实现逻辑 -->
72+
73+
```java
74+
75+
```
76+
77+
### **...**
78+
79+
```
80+
81+
```
82+
83+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# [1910. Remove All Occurrences of a Substring](https://leetcode.com/problems/remove-all-occurrences-of-a-substring)
2+
3+
[中文文档](/solution/1900-1999/1910.Remove%20All%20Occurrences%20of%20a%20Substring/README.md)
4+
5+
## Description
6+
7+
<p>Given two strings <code>s</code> and <code>part</code>, perform the following operation on <code>s</code> until <strong>all</strong> occurrences of the substring <code>part</code> are removed:</p>
8+
9+
<ul>
10+
<li>Find the <strong>leftmost</strong> occurrence of the substring <code>part</code> and <strong>remove</strong> it from <code>s</code>.</li>
11+
</ul>
12+
13+
<p>Return <code>s</code><em> after removing all occurrences of </em><code>part</code>.</p>
14+
15+
<p>A <strong>substring</strong> is a contiguous sequence of characters in a string.</p>
16+
17+
<p>&nbsp;</p>
18+
<p><strong>Example 1:</strong></p>
19+
20+
<pre>
21+
<strong>Input:</strong> s = &quot;daabcbaabcbc&quot;, part = &quot;abc&quot;
22+
<strong>Output:</strong> &quot;dab&quot;
23+
<strong>Explanation</strong>: The following operations are done:
24+
- s = &quot;da<strong><u>abc</u></strong>baabcbc&quot;, remove &quot;abc&quot; starting at index 2, so s = &quot;dabaabcbc&quot;.
25+
- s = &quot;daba<strong><u>abc</u></strong>bc&quot;, remove &quot;abc&quot; starting at index 4, so s = &quot;dababc&quot;.
26+
- s = &quot;dab<strong><u>abc</u></strong>&quot;, remove &quot;abc&quot; starting at index 3, so s = &quot;dab&quot;.
27+
Now s has no occurrences of &quot;abc&quot;.
28+
</pre>
29+
30+
<p><strong>Example 2:</strong></p>
31+
32+
<pre>
33+
<strong>Input:</strong> s = &quot;axxxxyyyyb&quot;, part = &quot;xy&quot;
34+
<strong>Output:</strong> &quot;ab&quot;
35+
<strong>Explanation</strong>: The following operations are done:
36+
- s = &quot;axxx<strong><u>xy</u></strong>yyyb&quot;, remove &quot;xy&quot; starting at index 4 so s = &quot;axxxyyyb&quot;.
37+
- s = &quot;axx<strong><u>xy</u></strong>yyb&quot;, remove &quot;xy&quot; starting at index 3 so s = &quot;axxyyb&quot;.
38+
- s = &quot;ax<strong><u>xy</u></strong>yb&quot;, remove &quot;xy&quot; starting at index 2 so s = &quot;axyb&quot;.
39+
- s = &quot;a<strong><u>xy</u></strong>b&quot;, remove &quot;xy&quot; starting at index 1 so s = &quot;ab&quot;.
40+
Now s has no occurrences of &quot;xy&quot;.
41+
</pre>
42+
43+
<p>&nbsp;</p>
44+
<p><strong>Constraints:</strong></p>
45+
46+
<ul>
47+
<li><code>1 &lt;= s.length &lt;= 1000</code></li>
48+
<li><code>1 &lt;= part.length &lt;= 1000</code></li>
49+
<li><code>s</code>​​​​​​ and <code>part</code> consists of lowercase English letters.</li>
50+
</ul>
51+
52+
53+
## Solutions
54+
55+
<!-- tabs:start -->
56+
57+
### **Python3**
58+
59+
```python
60+
61+
```
62+
63+
### **Java**
64+
65+
```java
66+
67+
```
68+
69+
### **...**
70+
71+
```
72+
73+
```
74+
75+
<!-- tabs:end -->

0 commit comments

Comments
 (0)