3
3
> Leetcode 刷题助手
4
4
> Leetcode Assistant
5
5
6
- ## Introduction
6
+ ## Features
7
7
一个GO CLI命令行工具辅助离线刷题记录。
8
- 功能如下:
9
- - 显示题目信息
10
- - 按题目tag整理分类
11
- - 支持Openai辅助答题
8
+ - 离线可使用
9
+ - 自动创建Leetcode题目和代码模板
10
+ - 按题目tag整理题目
11
+ - 接入Openai辅助答题
12
12
13
- ![ ] ( ./screenshots/all.png )
13
+ ### 题目分类
14
+ ![ ] ( ./screenshots/toc.png )
15
+ ![ ] ( ./screenshots/gpt.gif )
16
+
17
+ ## What's Next
18
+ - 接入notion api,使用notion管理做题进度
14
19
15
20
## Install
16
21
19
24
$ brew tap ppsteven/homebrew-tap
20
25
$ brew install ppsteven/homebrew-tap/leetcode-tool
21
26
22
- # 直接安装
23
- curl -fsSL https://bina.egoist.sh/zcong1993/leetcode-tool | sh
24
-
25
- # show help
26
27
$ leetcode-tool help
27
28
```
28
29
29
- ## Config 配置
30
-
31
- 可以在项目根目录创建 ` .leetcode.json ` 配置文件.
30
+ ## Getting Started
31
+ ![ ] ( ./screenshots/usage.gif )
32
+ ### 1. 新建配置文件 Config
33
+ 首先在创建一个做题目录,在目录下创建 ` .leetcode.json ` 配置文件.
32
34
33
- ``` js
35
+ ``` json
34
36
{
35
37
"lang" : " go/py3/ts/java" , // 项目全局语言, 配置后 new 命令 --lang 参数可省略, 目前支持 go ts js py3 java
36
38
"env" : " en/cn" ,
@@ -46,19 +48,53 @@ $ leetcode-tool help
46
48
- api_key: openai key
47
49
- model: openai model
48
50
49
- ## 使用说明
51
+ ### 2. 开始做题
50
52
51
- [ https://blog.cong.moe/post/2020-11-30-leetcode_tool ] ( https://blog.cong.moe/post/2020-11-30-leetcode_tool )
53
+ ``` bash
54
+ # 1. 新建一个题目
55
+ $ leetcode-tool new 1
56
+ # 2. 写出题解, 和测试代码
57
+ ...
58
+ ```
52
59
53
- ## 支持语言
60
+ 下面是自动生成的题目注释,通过编辑注释信息,帮助我们分类该题的解法。
61
+ ```
62
+ /**
63
+ * @index 1
64
+ * @title Two Sum
65
+ * @difficulty EASY
66
+ * @tags array,hash-table
67
+ * @draft false
68
+ * @link https://leetcode.cn/problems/two-sum/description/
69
+ * @frontendId 1
70
+ * @solved false
71
+ */
72
+ ```
73
+ - index: 题目编号
74
+ - title: 题目名称
75
+ - difficulty: 题目难易程度
76
+ - tags: 题目标签默认为Leetcode标签,同时也可以自定义标签
77
+ - draft: 是否草稿,true 则不会在update的时候对该题进行分类
78
+ - link: 题目链接
79
+ - frontendId: 题目编号
80
+ - solved: 是否解决
81
+
82
+ ``` bash
83
+ # 3. 更新 toc 文件
84
+ $ leetcode-tool update
85
+ # 4. 提交代码
86
+ ```
87
+
88
+ ## Support Language 支持语言
54
89
55
90
- Golang go
56
91
- Typescript ts
57
92
- Javascript js
58
93
- Python3 py3
59
94
- Java java
60
95
61
- ## 主要功能
96
+ ## Usage
97
+ > [ https://blog.cong.moe/post/2020-11-30-leetcode_tool ] ( https://blog.cong.moe/post/2020-11-30-leetcode_tool )
62
98
63
99
### 新建题目代码
64
100
@@ -103,55 +139,33 @@ leetcode-tool tags -f
103
139
# 2.1 假如你还保留了部分题解, 还需要更新下题目状态
104
140
leetcode-tool update
105
141
```
142
+ ## Troublesome
106
143
107
- ## Workflow
108
-
109
- 如何刷题?
110
-
144
+ 离线创建题目依赖 ` problems.json ` 文件,默认在本地无法获取该文件的时候,会从 [ PPsteven/leetcode-tool/problems.json] ( https://raw.githubusercontent.com/PPsteven/leetcode-tool/master/problems.json ) 下载。
145
+ 但是国内的用户可能由于网络原因无法下载,此时需要手动下载存放在吧本地目录中。
111
146
``` bash
112
- # 1. 新建一个题目
113
- $ leetcode-tool new 1
114
- # 2. 写出题解, 和测试代码
115
- ...
116
- # 3. 更新 toc 文件
117
- $ leetcode-tool update
118
- # 4. 提交代码
119
- ```
147
+ $ go run cmd/main.go new 1
148
+ file problems.json not exists, start downloading from https://raw.githubusercontent.com/PPsteven/leetcode-tool/master/problems.json
120
149
121
- 题目注释如何使用
122
-
123
- 下面是自动生成的题目注释,通过编辑注释信息,帮助我们分类该题的解法。
124
- ```
125
- /**
126
- * @index 1
127
- * @title Two Sum
128
- * @difficulty EASY
129
- * @tags array,hash-table
130
- * @draft false
131
- * @link https://leetcode.cn/problems/two-sum/description/
132
- * @frontendId 1
133
- * @solved false
134
- */
150
+ # 手动下载存放在代码编写目录
151
+ $ wget https://raw.githubusercontent.com/PPsteven/leetcode-tool/master/problems.json
135
152
```
136
- - index: 题目编号
137
- - title: 题目名称
138
- - difficulty: 题目难易程度
139
- - tags: 题目标签(可以自定义标签)
140
- - draft: 是否草稿,true 则不会在update的时候对该题进行分类
141
- - link: 题目链接
142
- - frontendId: 题目编号
143
- - solved: 是否解决
144
-
145
153
## 为什么需要这个工具
146
154
147
155
1 . leetcode 网页 IDE 太弱了, 我需要本地解题
148
156
1 . 网页题解难以沉淀, 例如一道题我希望整理多种解法
149
157
1 . GitHub 易于分享题解
150
158
1 . 根据自己需要, 组织题目做专题之类的总结
151
159
152
- ## 项目参考
153
- - 项目Fork自 https://github.com/zcong1993/leetcode-tool 此项目已多年不更新
154
- - Leetcode 题目爬取参考:https://github.com/bunnyxt/lcid
160
+ ## 鸣谢
161
+ > https://github.com/zcong1993/leetcode-tool
162
+
163
+ 此项目已多年不更新,本代码在Fork此仓库的基础上添加了如下功能:
164
+ - 离线下载了 Leetcode 3400+题,保证了在Leetcode接口发生改变后依然可以运行。
165
+ - 优化了部分代码逻辑
166
+ - 接入了Openai辅助解题
167
+
168
+ Leetcode 题目爬虫使用Python实现,详见 ` scripts ` 文件夹,代码参考:https://github.com/bunnyxt/lcid
155
169
156
170
## 使用此工具的项目
157
171
0 commit comments