Skip to content

Commit e85e492

Browse files
committed
feat: add solution list in README_EN file
1 parent e1abef0 commit e85e492

File tree

6 files changed

+1402
-7
lines changed

6 files changed

+1402
-7
lines changed
112 Bytes
Binary file not shown.

script/config.py

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
cn_graphql_url = 'https://leetcode-cn.com/graphql'
55
problems_url = 'https://leetcode-cn.com/problems/'
6+
en_problems_url = 'https://leetcode.com/problems/'
67
all_problems_url = 'https://leetcode.com/api/problems/all/'
78
lcof_problems_url = 'https://leetcode-cn.com/api/problems/lcof/'
89
lcci_problems_url = 'https://leetcode-cn.com/api/problems/lcci/'
@@ -29,6 +30,12 @@
2930
'3': '困难'
3031
}
3132

33+
difficulties_en = {
34+
'1': 'Easy',
35+
'2': 'Medium',
36+
'3': 'Hard'
37+
}
38+
3239

3340
# request
3441
@unique

script/leetcode_spider.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from urllib.parse import quote
33

44
from config import async_headers, cn_graphql_url, Req, all_problems_url, difficulties, lcof_problems_url, \
5-
lcci_problems_url, problems_url
5+
lcci_problems_url, problems_url, en_problems_url, difficulties_en
66
from fetch import fetch
77

88

@@ -62,13 +62,13 @@ def get_all_questions():
6262
int_id = question['stat']['question_id']
6363
qid = str(question['stat']['question_id']).zfill(4)
6464
title = question['stat']['question__title']
65-
link = problems_url + question['stat']['question__title_slug']
65+
link = en_problems_url + question['stat']['question__title_slug']
6666
pre = no_dict[str(int(int_id) // 100)]
67-
git_link = '/solution/{}/{}/README.md'.format(pre, qid + '.' + quote(title))
67+
git_link = '/solution/{}/{}/README_EN.md'.format(pre, qid + '.' + quote(title))
6868
cn_title = cn_res.get(qid) or title
6969
col1 = '[{}]({})'.format(qid, link)
70-
col2 = '[{}]({})'.format(cn_title, git_link)
71-
col3 = difficulties.get(str(question['difficulty']['level']))
70+
col2 = '[{}]({})'.format(title, git_link)
71+
col3 = difficulties_en.get(str(question['difficulty']['level']))
7272
yield [col1, col2, col3]
7373

7474

solution/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# LeetCode
22

3+
[English Version](./README_EN.md)
4+
35
## 题解
46
以下所有题目均来源 [LeetCode 中国官网](https://leetcode-cn.com/problemset/all),题解由 [doocs/leetcode 贡献者](https://github.com/doocs/leetcode/graphs/contributors) 提供,正在完善中,欢迎贡献你的题解!
57

0 commit comments

Comments
 (0)