Skip to content

Commit e1abef0

Browse files
committed
docs: add README_EN files
1 parent cb5a483 commit e1abef0

File tree

1,391 files changed

+72973
-1390
lines changed

Some content is hidden

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

1,391 files changed

+72973
-1390
lines changed
1.15 KB
Binary file not shown.
1.43 KB
Binary file not shown.

script/leetcode_spider.py

+25-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ def get_cn_questions() -> dict:
2828
final_res[qid] = q['title']
2929
return final_res
3030

31+
no_dict = {
32+
'0': '0000-0099',
33+
'1': '0100-0199',
34+
'2': '0200-0299',
35+
'3': '0300-0399',
36+
'4': '0400-0499',
37+
'5': '0500-0599',
38+
'6': '0600-0699',
39+
'7': '0700-0799',
40+
'8': '0800-0899',
41+
'9': '0900-0999',
42+
'10': '1000-1099',
43+
'11': '1100-1199',
44+
'12': '1200-1299',
45+
'13': '1300-1399',
46+
'14': '1400-1499',
47+
'15': '1500-1599',
48+
49+
}
50+
3151

3252
def get_all_questions():
3353
"""获取所有题目"""
@@ -39,10 +59,12 @@ def get_all_questions():
3959
questions = res['stat_status_pairs']
4060

4161
for question in questions:
62+
int_id = question['stat']['question_id']
4263
qid = str(question['stat']['question_id']).zfill(4)
4364
title = question['stat']['question__title']
4465
link = problems_url + question['stat']['question__title_slug']
45-
git_link = '/solution/{}/README.md'.format(qid + '.' + quote(title))
66+
pre = no_dict[str(int(int_id) // 100)]
67+
git_link = '/solution/{}/{}/README.md'.format(pre, qid + '.' + quote(title))
4668
cn_title = cn_res.get(qid) or title
4769
col1 = '[{}]({})'.format(qid, link)
4870
col2 = '[{}]({})'.format(cn_title, git_link)
@@ -103,5 +125,5 @@ def generate_md_table_for_questions(res):
103125

104126
if __name__ == '__main__':
105127
generate_md_table_for_questions(get_all_questions())
106-
generate_md_table_for_questions(get_lcof_questions())
107-
generate_md_table_for_questions(get_lcci_questions())
128+
# generate_md_table_for_questions(get_lcof_questions())
129+
# generate_md_table_for_questions(get_lcci_questions())

solution/0000-0099/0001.Two Sum/README_EN.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# [1. Two Sum](https://leetcode.com/problems/two-sum)
2+
3+
## Description
4+
<p>Given an array of integers, return <strong>indices</strong> of the two numbers such that they add up to a specific target.</p>
5+
6+
<p>You may assume that each input would have <strong><em>exactly</em></strong> one solution, and you may not use the <em>same</em> element twice.</p>
7+
8+
<p><strong>Example:</strong></p>
9+
10+
<pre>
11+
Given nums = [2, 7, 11, 15], target = 9,
12+
13+
Because nums[<strong>0</strong>] + nums[<strong>1</strong>] = 2 + 7 = 9,
14+
return [<strong>0</strong>, <strong>1</strong>].
15+
</pre>
16+
17+
18+
19+
## Solutions
20+
21+
22+
### Python3
23+
24+
```python
25+
26+
```
27+
28+
### Java
29+
30+
```java
31+
32+
```
33+
34+
### ...
35+
```
36+
37+
```

solution/0000-0099/0002.Add Two Numbers/README_EN.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# [2. Add Two Numbers](https://leetcode.com/problems/add-two-numbers)
2+
3+
## Description
4+
<p>You are given two <b>non-empty</b> linked lists representing two non-negative integers. The digits are stored in <b>reverse order</b> and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.</p>
5+
6+
<p>You may assume the two numbers do not contain any leading zero, except the number 0 itself.</p>
7+
8+
<p><b>Example:</b></p>
9+
10+
<pre>
11+
<b>Input:</b> (2 -&gt; 4 -&gt; 3) + (5 -&gt; 6 -&gt; 4)
12+
<b>Output:</b> 7 -&gt; 0 -&gt; 8
13+
<b>Explanation:</b> 342 + 465 = 807.
14+
</pre>
15+
16+
17+
18+
## Solutions
19+
20+
21+
### Python3
22+
23+
```python
24+
25+
```
26+
27+
### Java
28+
29+
```java
30+
31+
```
32+
33+
### ...
34+
```
35+
36+
```

solution/0000-0099/0003.Longest Substring Without Repeating Characters/README_EN.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# [3. Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters)
2+
3+
## Description
4+
<p>Given a string, find the length of the <b>longest substring</b> without repeating characters.</p>
5+
6+
<div>
7+
<p><strong>Example 1:</strong></p>
8+
9+
<pre>
10+
<strong>Input: </strong><span id="example-input-1-1">&quot;abcabcbb&quot;</span>
11+
<strong>Output: </strong><span id="example-output-1">3
12+
<strong>Explanation:</strong></span> The answer is <code>&quot;abc&quot;</code>, with the length of 3.
13+
</pre>
14+
15+
<div>
16+
<p><strong>Example 2:</strong></p>
17+
18+
<pre>
19+
<strong>Input: </strong><span id="example-input-2-1">&quot;bbbbb&quot;</span>
20+
<strong>Output: </strong><span id="example-output-2">1
21+
</span><span id="example-output-1"><strong>Explanation: </strong>T</span>he answer is <code>&quot;b&quot;</code>, with the length of 1.
22+
</pre>
23+
24+
<div>
25+
<p><strong>Example 3:</strong></p>
26+
27+
<pre>
28+
<strong>Input: </strong><span id="example-input-3-1">&quot;pwwkew&quot;</span>
29+
<strong>Output: </strong><span id="example-output-3">3
30+
</span><span id="example-output-1"><strong>Explanation: </strong></span>The answer is <code>&quot;wke&quot;</code>, with the length of 3.
31+
Note that the answer must be a <b>substring</b>, <code>&quot;pwke&quot;</code> is a <i>subsequence</i> and not a substring.
32+
</pre>
33+
</div>
34+
</div>
35+
</div>
36+
37+
38+
39+
## Solutions
40+
41+
42+
### Python3
43+
44+
```python
45+
46+
```
47+
48+
### Java
49+
50+
```java
51+
52+
```
53+
54+
### ...
55+
```
56+
57+
```

solution/0000-0099/0004.Median of Two Sorted Arrays/README_EN.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# [4. Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays)
2+
3+
## Description
4+
<p>There are two sorted arrays <b>nums1</b> and <b>nums2</b> of size m and n respectively.</p>
5+
6+
<p>Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).</p>
7+
8+
<p>You may assume <strong>nums1</strong> and <strong>nums2</strong>&nbsp;cannot be both empty.</p>
9+
10+
<p><b>Example 1:</b></p>
11+
12+
<pre>
13+
nums1 = [1, 3]
14+
nums2 = [2]
15+
16+
The median is 2.0
17+
</pre>
18+
19+
<p><b>Example 2:</b></p>
20+
21+
<pre>
22+
nums1 = [1, 2]
23+
nums2 = [3, 4]
24+
25+
The median is (2 + 3)/2 = 2.5
26+
</pre>
27+
28+
29+
30+
## Solutions
31+
32+
33+
### Python3
34+
35+
```python
36+
37+
```
38+
39+
### Java
40+
41+
```java
42+
43+
```
44+
45+
### ...
46+
```
47+
48+
```

solution/0000-0099/0005.Longest Palindromic Substring/README_EN.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# [5. Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring)
2+
3+
## Description
4+
<p>Given a string <strong>s</strong>, find the longest palindromic substring in <strong>s</strong>. You may assume that the maximum length of <strong>s</strong> is 1000.</p>
5+
6+
<p><strong>Example 1:</strong></p>
7+
8+
<pre>
9+
<strong>Input:</strong> &quot;babad&quot;
10+
<strong>Output:</strong> &quot;bab&quot;
11+
<strong>Note:</strong> &quot;aba&quot; is also a valid answer.
12+
</pre>
13+
14+
<p><strong>Example 2:</strong></p>
15+
16+
<pre>
17+
<strong>Input:</strong> &quot;cbbd&quot;
18+
<strong>Output:</strong> &quot;bb&quot;
19+
</pre>
20+
21+
22+
23+
## Solutions
24+
25+
26+
### Python3
27+
28+
```python
29+
30+
```
31+
32+
### Java
33+
34+
```java
35+
36+
```
37+
38+
### ...
39+
```
40+
41+
```

solution/0000-0099/0006.ZigZag Conversion/README_EN.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# [6. ZigZag Conversion](https://leetcode.com/problems/zigzag-conversion)
2+
3+
## Description
4+
<p>The string <code>&quot;PAYPALISHIRING&quot;</code> is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)</p>
5+
6+
<pre>
7+
P A H N
8+
A P L S I I G
9+
Y I R
10+
</pre>
11+
12+
<p>And then read line by line: <code>&quot;PAHNAPLSIIGYIR&quot;</code></p>
13+
14+
<p>Write the code that will take a string and make this conversion given a number of rows:</p>
15+
16+
<pre>
17+
string convert(string s, int numRows);</pre>
18+
19+
<p><strong>Example 1:</strong></p>
20+
21+
<pre>
22+
<strong>Input:</strong> s = &quot;PAYPALISHIRING&quot;, numRows = 3
23+
<strong>Output:</strong> &quot;PAHNAPLSIIGYIR&quot;
24+
</pre>
25+
26+
<p><strong>Example 2:</strong></p>
27+
28+
<pre>
29+
<strong>Input:</strong> s = &quot;PAYPALISHIRING&quot;, numRows =&nbsp;4
30+
<strong>Output:</strong>&nbsp;&quot;PINALSIGYAHRPI&quot;
31+
<strong>Explanation:</strong>
32+
33+
P I N
34+
A L S I G
35+
Y A H R
36+
P I</pre>
37+
38+
39+
40+
## Solutions
41+
42+
43+
### Python3
44+
45+
```python
46+
47+
```
48+
49+
### Java
50+
51+
```java
52+
53+
```
54+
55+
### ...
56+
```
57+
58+
```

solution/0000-0099/0007.Reverse Integer/README_EN.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# [7. Reverse Integer](https://leetcode.com/problems/reverse-integer)
2+
3+
## Description
4+
<p>Given a 32-bit signed integer, reverse digits of an integer.</p>
5+
6+
<p><strong>Example 1:</strong></p>
7+
8+
<pre>
9+
<strong>Input:</strong> 123
10+
<strong>Output:</strong> 321
11+
</pre>
12+
13+
<p><strong>Example 2:</strong></p>
14+
15+
<pre>
16+
<strong>Input:</strong> -123
17+
<strong>Output:</strong> -321
18+
</pre>
19+
20+
<p><strong>Example 3:</strong></p>
21+
22+
<pre>
23+
<strong>Input:</strong> 120
24+
<strong>Output:</strong> 21
25+
</pre>
26+
27+
<p><strong>Note:</strong><br />
28+
Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [&minus;2<sup>31</sup>,&nbsp; 2<sup>31&nbsp;</sup>&minus; 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.</p>
29+
30+
31+
32+
## Solutions
33+
34+
35+
### Python3
36+
37+
```python
38+
39+
```
40+
41+
### Java
42+
43+
```java
44+
45+
```
46+
47+
### ...
48+
```
49+
50+
```

0 commit comments

Comments
 (0)