Skip to content

Commit cc937dc

Browse files
authored
refactor: update problem template (doocs#2824)
1 parent 8640250 commit cc937dc

File tree

6,808 files changed

+79707
-10374
lines changed

Some content is hidden

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

6,808 files changed

+79707
-10374
lines changed

basic/sorting/BubbleSort/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -217,5 +217,3 @@ public class Program
217217
```
218218

219219
<!-- tabs:end -->
220-
221-
<!-- end -->

basic/sorting/HeapSort/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ func main() {
286286
}
287287
```
288288

289-
<!-- tabs:end -->## 解法
289+
<!-- tabs:end -->
290+
291+
## 解法
290292

291293
### 方法一
292294

@@ -500,5 +502,3 @@ fn main() -> io::Result<()> {
500502
```
501503

502504
<!-- tabs:end -->
503-
504-
<!-- end -->

basic/sorting/InsertionSort/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -197,5 +197,3 @@ public class Program
197197
```
198198

199199
<!-- tabs:end -->
200-
201-
<!-- end -->

basic/sorting/MergeSort/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -362,5 +362,3 @@ process.stdin.on('end', function () {
362362
```
363363

364364
<!-- tabs:end -->
365-
366-
<!-- end -->

basic/sorting/QuickSort/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -319,5 +319,3 @@ process.stdin.on('end', function () {
319319
```
320320

321321
<!-- tabs:end -->
322-
323-
<!-- end -->

basic/sorting/SelectionSort/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -199,5 +199,3 @@ public class Program
199199
```
200200

201201
<!-- tabs:end -->
202-
203-
<!-- end -->

basic/sorting/ShellSort/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,3 @@ console.log(shellSort(arr));
114114
```
115115

116116
<!-- tabs:end -->
117-
118-
<!-- end -->

lcci/01.01.Is Unique/README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ difficulty: 简单
44
edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.01.Is%20Unique/README.md
55
---
66

7+
<!-- problem:start -->
8+
79
# [面试题 01.01. 判定字符是否唯一](https://leetcode.cn/problems/is-unique-lcci)
810

911
[English Version](/lcci/01.01.Is%20Unique/README_EN.md)
1012

1113
## 题目描述
1214

13-
<!-- 这里写题目描述 -->
15+
<!-- description:start -->
16+
1417
<p>实现一个算法,确定一个字符串 <code>s</code> 的所有字符是否全都不同。</p>
1518

1619
<p><strong>示例 1:</strong></p>
@@ -31,8 +34,12 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.01.Is%20Unique/REA
3134
<li>如果你不使用额外的数据结构,会很加分。</li>
3235
</ul>
3336

37+
<!-- description:end -->
38+
3439
## 解法
3540

41+
<!-- solution:start -->
42+
3643
### 方法一:位运算
3744

3845
根据示例,可以假定字符串中只包含小写字母(实际验证,也符合假设)。
@@ -152,4 +159,6 @@ class Solution {
152159

153160
<!-- tabs:end -->
154161

155-
<!-- end -->
162+
<!-- solution:end -->
163+
164+
<!-- problem:end -->

lcci/01.01.Is Unique/README_EN.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ difficulty: Easy
44
edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.01.Is%20Unique/README_EN.md
55
---
66

7+
<!-- problem:start -->
8+
79
# [01.01. Is Unique](https://leetcode.cn/problems/is-unique-lcci)
810

911
[中文文档](/lcci/01.01.Is%20Unique/README.md)
1012

1113
## Description
1214

15+
<!-- description:start -->
16+
1317
<p>Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures?</p>
1418

1519
<p><strong>Example 1:</strong></p>
@@ -38,8 +42,12 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.01.Is%20Unique/REA
3842
<li><code>0 &lt;= len(s) &lt;= 100 </code></li>
3943
</ul>
4044

45+
<!-- description:end -->
46+
4147
## Solutions
4248

49+
<!-- solution:start -->
50+
4351
### Solution 1: Bit Manipulation
4452

4553
Based on the examples, we can assume that the string only contains lowercase letters (which is confirmed by actual verification).
@@ -159,4 +167,6 @@ class Solution {
159167

160168
<!-- tabs:end -->
161169

162-
<!-- end -->
170+
<!-- solution:end -->
171+
172+
<!-- problem:end -->

lcci/01.02.Check Permutation/README.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ difficulty: 简单
44
edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.02.Check%20Permutation/README.md
55
---
66

7+
<!-- problem:start -->
8+
79
# [面试题 01.02. 判定是否互为字符重排](https://leetcode.cn/problems/check-permutation-lcci)
810

911
[English Version](/lcci/01.02.Check%20Permutation/README_EN.md)
1012

1113
## 题目描述
1214

13-
<!-- 这里写题目描述 -->
15+
<!-- description:start -->
16+
1417
<p>给定两个字符串 <code>s1</code> 和 <code>s2</code>,请编写一个程序,确定其中一个字符串的字符重新排列后,能否变成另一个字符串。</p>
1518

1619
<p><strong>示例 1:</strong></p>
@@ -32,8 +35,12 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.02.Check%20Permuta
3235
<li><code>0 &lt;= len(s2) &lt;= 100 </code></li>
3336
</ul>
3437

38+
<!-- description:end -->
39+
3540
## 解法
3641

42+
<!-- solution:start -->
43+
3744
### 方法一:数组或哈希表
3845

3946
我们先判断两个字符串的长度是否相等,若不相等则直接返回 `false`
@@ -205,6 +212,10 @@ class Solution {
205212

206213
<!-- tabs:end -->
207214

215+
<!-- solution:end -->
216+
217+
<!-- solution:start-->
218+
208219
### 方法二:排序
209220

210221
我们也按照字典序对两个字符串进行排序,然后比较两个字符串是否相等。
@@ -271,4 +282,6 @@ impl Solution {
271282

272283
<!-- tabs:end -->
273284

274-
<!-- end -->
285+
<!-- solution:end -->
286+
287+
<!-- problem:end -->

lcci/01.02.Check Permutation/README_EN.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ difficulty: Easy
44
edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.02.Check%20Permutation/README_EN.md
55
---
66

7+
<!-- problem:start -->
8+
79
# [01.02. Check Permutation](https://leetcode.cn/problems/check-permutation-lcci)
810

911
[中文文档](/lcci/01.02.Check%20Permutation/README.md)
1012

1113
## Description
1214

15+
<!-- description:start -->
16+
1317
<p>Given two strings,write a method to decide if one is a permutation of the other.</p>
1418

1519
<p><strong>Example 1:</strong></p>
@@ -38,8 +42,12 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.02.Check%20Permuta
3842
<li><code>0 &lt;= len(s2) &lt;= 100</code></li>
3943
</ol>
4044

45+
<!-- description:end -->
46+
4147
## Solutions
4248

49+
<!-- solution:start -->
50+
4351
### Solution 1: Array or Hash Table
4452

4553
First, we check whether the lengths of the two strings are equal. If they are not equal, we directly return `false`.
@@ -211,6 +219,10 @@ class Solution {
211219

212220
<!-- tabs:end -->
213221

222+
<!-- solution:end -->
223+
224+
<!-- solution:start -->
225+
214226
### Solution 2: Sorting
215227

216228
We can also sort the two strings in lexicographical order, and then compare whether the two strings are equal.
@@ -277,4 +289,6 @@ impl Solution {
277289

278290
<!-- tabs:end -->
279291

280-
<!-- end -->
292+
<!-- solution:end -->
293+
294+
<!-- problem:end -->

lcci/01.03.String to URL/README.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ difficulty: 简单
44
edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.03.String%20to%20URL/README.md
55
---
66

7+
<!-- problem:start -->
8+
79
# [面试题 01.03. URL 化](https://leetcode.cn/problems/string-to-url-lcci)
810

911
[English Version](/lcci/01.03.String%20to%20URL/README_EN.md)
1012

1113
## 题目描述
1214

13-
<!-- 这里写题目描述 -->
15+
<!-- description:start -->
16+
1417
<p>URL化。编写一种方法,将字符串中的空格全部替换为<code>%20</code>。假定该字符串尾部有足够的空间存放新增字符,并且知道字符串的&ldquo;真实&rdquo;长度。(注:用<code>Java</code>实现的话,请使用字符数组实现,以便直接在数组上操作。)</p>
1518

1619
<p><strong>示例1:</strong></p>
@@ -31,8 +34,12 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.03.String%20to%20U
3134
<li>字符串长度在[0, 500000]范围内。</li>
3235
</ol>
3336

37+
<!-- description:end -->
38+
3439
## 解法
3540

41+
<!-- solution:start -->
42+
3643
### 方法一:使用 `replace()` 函数
3744

3845
直接利用 `replace` 将所有 ` ` 替换为 `%20`
@@ -93,6 +100,10 @@ class Solution {
93100

94101
<!-- tabs:end -->
95102

103+
<!-- solution:end -->
104+
105+
<!-- solution:start-->
106+
96107
### 方法二:模拟
97108

98109
遍历字符串每个字符 $c$,遇到空格则将 `%20` 添加到结果中,否则添加 $c$。
@@ -161,4 +172,6 @@ impl Solution {
161172

162173
<!-- tabs:end -->
163174

164-
<!-- end -->
175+
<!-- solution:end -->
176+
177+
<!-- problem:end -->

lcci/01.03.String to URL/README_EN.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ difficulty: Easy
44
edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.03.String%20to%20URL/README_EN.md
55
---
66

7+
<!-- problem:start -->
8+
79
# [01.03. String to URL](https://leetcode.cn/problems/string-to-url-lcci)
810

911
[中文文档](/lcci/01.03.String%20to%20URL/README.md)
1012

1113
## Description
1214

15+
<!-- description:start -->
16+
1317
<p>Write a method to replace all spaces in a string with &#39;%20&#39;. You may assume that the string has sufficient space at the end to hold the additional characters,and that you are given the &quot;true&quot; length of the string. (Note: If implementing in Java,please use a character array so that you can perform this operation in place.)</p>
1418

1519
<p><strong>Example 1:</strong></p>
@@ -44,8 +48,12 @@ The missing numbers are [5,6,8,...], hence the third missing number is 8.
4448
<li><code>0 &lt;= S.length &lt;= 500000</code></li>
4549
</ol>
4650

51+
<!-- description:end -->
52+
4753
## Solutions
4854

55+
<!-- solution:start -->
56+
4957
### Solution 1: Using `replace()` function
5058

5159
Directly use `replace` to replace all ` ` with `%20`:
@@ -106,6 +114,10 @@ class Solution {
106114

107115
<!-- tabs:end -->
108116

117+
<!-- solution:end -->
118+
119+
<!-- solution:start -->
120+
109121
### Solution 2: Simulation
110122

111123
Traverse each character $c$ in the string. When encountering a space, add `%20` to the result, otherwise add $c$.
@@ -174,4 +186,6 @@ impl Solution {
174186

175187
<!-- tabs:end -->
176188

177-
<!-- end -->
189+
<!-- solution:end -->
190+
191+
<!-- problem:end -->

lcci/01.04.Palindrome Permutation/README.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ difficulty: 简单
44
edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.04.Palindrome%20Permutation/README.md
55
---
66

7+
<!-- problem:start -->
8+
79
# [面试题 01.04. 回文排列](https://leetcode.cn/problems/palindrome-permutation-lcci)
810

911
[English Version](/lcci/01.04.Palindrome%20Permutation/README_EN.md)
1012

1113
## 题目描述
1214

13-
<!-- 这里写题目描述 -->
15+
<!-- description:start -->
16+
1417
<p>给定一个字符串,编写一个函数判定其是否为某个回文串的排列之一。</p>
1518

1619
<p>回文串是指正反两个方向都一样的单词或短语。排列是指字母的重新排列。</p>
@@ -27,8 +30,12 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcci/01.04.Palindrome%20Pe
2730

2831
<p>&nbsp;</p>
2932

33+
<!-- description:end -->
34+
3035
## 解法
3136

37+
<!-- solution:start -->
38+
3239
### 方法一:哈希表
3340

3441
我们用哈希表 $cnt$ 存储每个字符出现的次数。若次数为奇数的字符超过 $1$ 个,则不是回文排列。
@@ -146,6 +153,10 @@ class Solution {
146153

147154
<!-- tabs:end -->
148155

156+
<!-- solution:end -->
157+
158+
<!-- solution:start-->
159+
149160
### 方法二:哈希表的另一种实现
150161

151162
我们用哈希表 $vis$ 存储每个字符是否出现过。若出现过,则从哈希表中删除该字符;否则,将该字符加入哈希表。
@@ -202,4 +213,6 @@ public:
202213
203214
<!-- tabs:end -->
204215
205-
<!-- end -->
216+
<!-- solution:end -->
217+
218+
<!-- problem:end -->

0 commit comments

Comments
 (0)