Skip to content

Commit de96158

Browse files
committed
docs:add examples to explain how to use
1 parent 0b8ecf0 commit de96158

File tree

8 files changed

+75
-202
lines changed

8 files changed

+75
-202
lines changed

README.md

+21-190
Original file line numberDiff line numberDiff line change
@@ -1,211 +1,42 @@
11
# Leetcode practice
22

3-
在力扣练习平台!开始你的每日一题!
3+
[中文文档](docs/README_CN.md)|**英文文档**|[日文文档](docs/README_JP.md)|[韩文文档](docs/README_KR.md)
44

5-
在编辑器中编写你的代码,简单有效的执行和计时!
5+
## Introduction
66

7-
我们的目标就是让所有人:
8-
> 只用专注于代码的实现,而非繁琐的输入输出!
7+
A brief introduction: "Start practicing your daily LeetCode questions in the editor!"
98

10-
![CLI-lc](resources/images/cli-lc.png)
9+
If you want to write your solutions in the editor...
1110

12-
## How to use for your self?
11+
If you want to quickly access daily questions...
1312

14-
### Plan A (Recommended)
15-
The best way to use is by using the `lk/lf/lc` command in your terminal.
13+
If you want to create your own solution repository...
1614

17-
### Plan B (Supported)
18-
You can also use the `fork` command on github.com to create your own repository.
15+
Then, leetcode-practice will meet all your needs!
1916

20-
### Plan C (Supported)
21-
We also publish a plugin for `WebStorm` and `VS Code`. You can easily use it to create your question.
17+
## Preview
2218

23-
## Preparation
19+
![CLI-lc](resources/images/lc-cli-h.png)
2420

25-
只需要一个node环境即可.([如何安装node?点我了解](https://nodejs.org/en/learn/getting-started/how-to-install-nodejs))
21+
## How should I use it? (Three options for you to choose from)
2622

27-
| 依赖包 | 版本 |
28-
|--------|-------|
29-
| nodejs | `lts` |
23+
### Option A: CLI (Recommended)
3024

31-
## Installation
25+
The best and most flexible way to use it is to use our CLI in the terminal. You can create and check your solutions using three core commands: `lk`, `lf`, and `lc`.
3226

33-
### Global installation for cli (for plan A)
34-
1. npm install -g leetcode-practice
35-
### Using fork to make your leetcode-practice repository (for plan B)
27+
### Option B: Fork (Supported)
3628

37-
### Install plugin on your editor[WebStorm/VS code] (for plan C)
29+
You can also use GitHub's fork feature to create a copy of our project. Then, you can directly use the built-in commands within the project to create and check solutions.
3830

31+
### Option C: Plugin (Supported)
3932

40-
## Usage
41-
### 0. 安装依赖
33+
You can also use our `leetcode-practice` plugin available in the plugin marketplace for interactive creation and checking of solutions. (Supported on two popular editors: `WebStorm` and `VS Code`)
4234

43-
```shell
44-
yarn install # 或者任意你喜欢的包管理工具,如
45-
pnpm install
46-
```
35+
## Prerequisites
4736

48-
### 1. 获取今天的题目
37+
For any option, you only need a Node environment. ([Don't know how to install Node? Click here to learn more](https://nodejs.org/en/learn/getting-started/how-to-install-nodejs))
4938

50-
```shell
51-
yarn leet-create
52-
```
39+
| Dependency | Version |
40+
|------------|---------|
41+
| Node.js | `lts` |
5342

54-
会通过接口获取今日题目,并会在`src`目录下根据`题目的id`+`题目的英文翻译`创建一个目录,并将今日题目和基础示例代码填充到`index.js`中。
55-
56-
![创建目录](resources/images/leet-create-0.png)
57-
![填充文件](resources/images/leet-create-1.png)
58-
59-
### 2. 检验今天的题目
60-
61-
```shell
62-
yarn leet-check
63-
```
64-
65-
此指令会根据今天的题目信息去执行对应的题目文件,输出结果。
66-
67-
```shell
68-
yarn leet-check
69-
70-
[leet-check]检测题目:2744.find-maximum-number-of-string-pairs
71-
执行结果:
72-
┌─────────┬──────────┬──────────┬──────────┬────────────┬───────────┐
73-
│ (index) │ 测试结果 │ 预期结果 │ 执行结果 │ 执行用时 │ 内存占用 │
74-
├─────────┼──────────┼──────────┼──────────┼────────────┼───────────┤
75-
│ 0 │ '通过''2''2''0.2113ms''1.68 KB'
76-
│ 1 │ '通过''1''1''0.0195ms''1.73 KB'
77-
│ 2 │ '通过''0''0''0.0091ms''1.80 KB'
78-
└─────────┴──────────┴──────────┴──────────┴────────────┴───────────┘
79-
点击跳转到题目提交:https://leetcode.cn/problems/find-maximum-number-of-string-pairs/
80-
81-
Done in 0.18s.
82-
83-
```
84-
85-
![检测题目](resources/images/leet-check.png)
86-
87-
### 3. 创建自己想要练习的题目
88-
89-
```shell
90-
# 可以使用你喜欢的任意包管理工具,例如 `pnpm`/`npm`
91-
yarn leet-create -i [题目编号或者名称]
92-
93-
# e.g.
94-
yarn leet-create -i 1314
95-
#注意如果遇到id带空格的题目,请使用字符串包裹
96-
# e.g.
97-
yarn leet-create -i "LCP 29"
98-
```
99-
100-
然后会在目录中创建一个模板js文件,目录结构为:
101-
102-
```shell
103-
-src
104-
└── 1314
105-
└── index.js # 模板js文件 可以替换题目
106-
```
107-
108-
![1314cmd.png](resources/images/1314-cmd.png)
109-
![1314.png](resources/images/1314.png)
110-
![1314详情.png](resources/images/1314-detail.png)
111-
112-
### 4. 检验自己想要练习的结果
113-
114-
```shell
115-
# 可以使用你喜欢的任意包管理工具,例如 `pnpm`/`npm`
116-
yarn leet-check -i [题目编号或者名称]
117-
118-
e.g.
119-
yarn leet-check -i 1314
120-
```
121-
122-
会出现其用时以及内存占用:
123-
124-
```shell
125-
D:\GitHub\leetcode-practice> yarn leet-check -i 1314
126-
yarn run v1.22.19
127-
$ node common/scripts/check.js -i 1314
128-
[leet-check]检测题目:1314.matrix-block-sum
129-
执行结果:
130-
┌─────────┬──────────┬──────────────────────────────────────┬──────────────────────────────────────┬────────────┬───────────┐
131-
│ (index) │ 测试结果 │ 预期结果 │ 执行结果 │ 执行用时 │ 内存占用 │
132-
├─────────┼──────────┼──────────────────────────────────────┼──────────────────────────────────────┼────────────┼───────────┤
133-
│ 0 │ '通过''[[12,21,16],[27,45,33],[24,39,28]]''[[12,21,16],[27,45,33],[24,39,28]]''0.2553ms''2.05 KB'
134-
│ 1 │ '通过''[[45,45,45],[45,45,45],[45,45,45]]''[[45,45,45],[45,45,45],[45,45,45]]''0.0224ms''2.13 KB'
135-
└─────────┴──────────┴──────────────────────────────────────┴──────────────────────────────────────┴────────────┴───────────┘
136-
点击跳转到题目提交:https://leetcode.cn/problems/matrix-block-sum/
137-
138-
Done in 0.18s.
139-
140-
```
141-
142-
当然如果你之前执行了`leet-create -i`指令创建的题目,也可以不指定号码,系统会自动读取上一个指定创建的题目进行监测。
143-
144-
```shell
145-
D:\GitHub\leetcode-practice> yarn leet-check -i
146-
yarn run v1.22.19
147-
$ node common/scripts/check.js -i
148-
[leet-check]检测题目:1314.matrix-block-sum
149-
执行结果:
150-
┌─────────┬──────────┬──────────────────────────────────────┬──────────────────────────────────────┬────────────┬───────────┐
151-
│ (index) │ 测试结果 │ 预期结果 │ 执行结果 │ 执行用时 │ 内存占用 │
152-
├─────────┼──────────┼──────────────────────────────────────┼──────────────────────────────────────┼────────────┼───────────┤
153-
│ 0 │ '通过''[[12,21,16],[27,45,33],[24,39,28]]''[[12,21,16],[27,45,33],[24,39,28]]''0.2537ms''2.05 KB'
154-
│ 1 │ '通过''[[45,45,45],[45,45,45],[45,45,45]]''[[45,45,45],[45,45,45],[45,45,45]]''0.0231ms''2.13 KB'
155-
└─────────┴──────────┴──────────────────────────────────────┴──────────────────────────────────────┴────────────┴───────────┘
156-
点击跳转到题目提交:https://leetcode.cn/problems/matrix-block-sum/
157-
158-
Done in 0.19s.
159-
160-
```
161-
162-
![1314-check.png](resources/images/1314-check.png)
163-
164-
### 5. 获取随机题目
165-
166-
```shell
167-
yarn leet-create -r
168-
```
169-
170-
会获取一个当前src目录中未出现过的题目并创建:
171-
172-
```shell
173-
D:\GitHub\leetcode-practice> yarn leet-create -r
174-
yarn run v1.22.19
175-
$ node common/scripts/create.js -r
176-
[fulfillQuestion]题目[43][字符串相乘]已完成填充.
177-
Done in 1.78s.
178-
```
179-
180-
### 6. 检验随机题目
181-
182-
```shell
183-
# 可以使用你喜欢的任意包管理工具,例如 `pnpm`/`npm`
184-
yarn leet-check -r
185-
```
186-
187-
会检验刚刚创建出的随机题目:
188-
189-
```shell
190-
D:\GitHub\leetcode-practice> yarn leet-check -r
191-
yarn run v1.22.19
192-
$ node common/scripts/check.js -r
193-
[leet-check]检测当前随机题目:43.multiply-strings
194-
执行结果:
195-
┌─────────┬──────────┬───────────┬───────────┬────────────┬───────────┐
196-
│ (index) │ 测试结果 │ 预期结果 │ 执行结果 │ 执行用时 │ 内存占用 │
197-
├─────────┼──────────┼───────────┼───────────┼────────────┼───────────┤
198-
│ 0 │ '通过''"6"''"6"''0.2153ms''1.76 KB'
199-
│ 1 │ '通过''"56088"''"56088"''0.0232ms''2.02 KB'
200-
└─────────┴──────────┴───────────┴───────────┴────────────┴───────────┘
201-
点击跳转到题目提交:https://leetcode.cn/problems/multiply-strings/
202-
203-
Done in 0.19s.
204-
205-
```
206-
207-
## Contributor
208-
209-
[<img src="https://avatars.githubusercontent.com/u/48346853" style="border-radius:50%;" width="30" height="30" alt="EternalHeart"/>](https://github.com/wh131462)
210-
[<img src="https://avatars.githubusercontent.com/u/61453917" style="border-radius:50%;" width="30" height="30" alt="SmartTeddy"/>](https://github.com/SmallTeddy)
211-
[<img src="https://avatars.githubusercontent.com/u/35305691" style="border-radius:50%;" width="30" height="30" alt="Hedwig-Fang"/>](https://github.com/Hedwig-Fang)

bin/lc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /usr/bin/env node
22
import {program} from "commander";
33
import {artFontLogo} from "#resources/text/art-font-logo.js";
4-
import {examples} from "#resources/text/examples.js";
4+
import {lcExamples} from "#resources/text/examples.js";
55
import {love} from "#resources/text/love.js";
66
import {aim} from "#resources/text/aim.js";
77
import {referMode} from "#common/utils/create-check/refer-mode.js";
@@ -23,7 +23,7 @@ const version = process.env.VERSION??'0.0.0';
2323
program
2424
.version(version)
2525
.description(`${description}\n${artFontLogo}\n${aim}`)
26-
.addHelpText('after', examples+love)
26+
.addHelpText('after', lcExamples+love)
2727
.arguments("[identity]")
2828
.option('-t, --today', 'Get a question today.')
2929
.option('-i, --identity <identity>', 'Specify a question by identity.')

bin/lk.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /usr/bin/env node
22
import {program} from "commander";
33
import {artFontLogo} from "#resources/text/art-font-logo.js";
4-
import {examples} from "#resources/text/examples.js";
4+
import {lkExamples} from "#resources/text/examples.js";
55
import {love} from "#resources/text/love.js";
66
import {aim} from "#resources/text/aim.js";
77
import {referMode} from "#common/utils/create-check/refer-mode.js";
@@ -21,7 +21,7 @@ const version = process.env.VERSION ?? '0.0.0';
2121
program
2222
.version(version)
2323
.description(`${description}\n${artFontLogo}\n${aim}`)
24-
.addHelpText('after', examples + love)
24+
.addHelpText('after', lkExamples + love)
2525
.arguments("[identity]")
2626
.option('-t, --today', 'Check the question today.')
2727
.option('-i, --identity <identity>', 'Check the specified question by identity.')

docs/README_CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
## 预览
1818

19-
![CLI-lc](../resources/images/cli-lc.png)
19+
![CLI-lc](../resources/images/lc-cli-h.png)
2020

2121
## 我应该怎么使用?(三种方案供你选择)
2222

resources/images/cli-lc.png

-293 KB
Binary file not shown.

resources/images/lc-cli-h.png

461 KB
Loading

resources/text/description.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const description = `
22
A powerful practice platform for leetcode.
33
CLI / Template Project / Plugin, you can create question by any way you like.
4+
See https://github.com/wh131462/leetcode-practice
45
`;

resources/text/examples.js

+48-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,50 @@
1-
export const examples = `
1+
export const lcExamples = `
22
Examples:
3-
$ lc // Get a question today
4-
$ lc -t // Full text command to get a question today
5-
$ lc 1314 // Get the question by identity
6-
$ lc -i 1314 // Full text command to get the question by identity
7-
$ lc -r // Get a question randomly
3+
# Command with no parameters
4+
$ lc // Get a question for today.
5+
$ lc 1314 // Get a question by its identity.
6+
# Exclusive commands
7+
$ lc -t // Full text command to get a question for today.
8+
$ lc -i 1314 // Full text command to get a question by its identity.
9+
$ lc -r // Get a question randomly.
10+
# Other instructions
11+
$ lc -e // Easy mode to create a question.
12+
$ lc -d src // Use the relative path to the source folder.
13+
$ lc -u // Check the version to determine whether to update to the latest one.
14+
$ lc -v // Check the CLI version.
15+
$ lc -h // Check the help information.
16+
17+
`;
818

9-
`
19+
export const lkExamples = `
20+
Examples:
21+
# Command with no parameters
22+
$ lk // Check today's question.
23+
$ lk 1314 // Check the question by its ID.
24+
# Exclusive commands
25+
$ lk -t // Full text command to check today's question.
26+
$ lk -i 1314 // Full text command to check the question by its ID.
27+
$ lk -r // Check a randomly generated question.
28+
# Other instructions
29+
$ lk -e // Easy mode to check a question.
30+
$ lk -d src // Use the relative path to the source folder.
31+
$ lk -u // Check the version to determine whether to update to the latest one.
32+
$ lk -v // Check the CLI version.
33+
$ lk -h // Display the help information.
34+
35+
`;
36+
37+
export const lfExamples = `
38+
Examples:
39+
# Command with no parameters
40+
41+
# Exclusive commands
42+
43+
# Other instructions
44+
$ lf -e // Easy mode to check a question.
45+
$ lf -d src // Use the relative path to the source folder.
46+
$ lf -u // Check the version to determine whether to update to the latest one.
47+
$ lf -v // Check the CLI version.
48+
$ lf -h // Display the help information.
49+
50+
`;

0 commit comments

Comments
 (0)