Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0e8c7a6

Browse files
committed
Refactor README to use docs/
Signed-off-by: Eric Wang <skygragon@gmail.com>
1 parent 4ba38d5 commit 0e8c7a6

File tree

7 files changed

+138
-105
lines changed

7 files changed

+138
-105
lines changed

README.md

Lines changed: 5 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# leetcode-cli-plugins
22
3rd party plugins for leetcode-cli.
33

4-
* [company.js](#company)
5-
* [cpp.lint.js](#cpplint)
6-
* [cpp.run.js](#cpprun)
7-
* [solution.discuss](#solutiondiscuss)
4+
* [company.js](/docs/company.md)
5+
* [cpp.lint.js](/docs/cpp.lint.md)
6+
* [cpp.run.js](/docs/cpp.run.md)
7+
* [solution.discuss](/docs/solution.discuss.md)
88

99
## HOWTO
1010

@@ -14,104 +14,4 @@ You can install the plugins in either ways below:
1414

1515
$ leetcode plugin -i <plugin file>
1616

17-
To manage the installed plugins, please check [leetcode-cli's user guide](https://skygragon.github.io/leetcode-cli/commands#plugin).
18-
19-
## Plugins
20-
21-
### Company
22-
23-
* use `list` + `-t` to filter by company.
24-
25-
Filter questions by company tag.
26-
27-
$ leetcode list -q hL -t facebook
28-
29-
[410] Split Array Largest Sum Hard (36.60 %)
30-
✔ [301] Remove Invalid Parentheses Hard (35.03 %)
31-
✔ [297] Serialize and Deserialize Binary Tree Hard (33.12 %)
32-
[282] Expression Add Operators Hard (29.55 %)
33-
[273] Integer to English Words Hard (21.98 %)
34-
[218] The Skyline Problem Hard (27.00 %)
35-
✔ [146] LRU Cache Hard (17.53 %)
36-
✔ [128] Longest Consecutive Sequence Hard (36.63 %)
37-
✔ [ 85] Maximal Rectangle Hard (27.66 %)
38-
✔ [ 76] Minimum Window Substring Hard (25.14 %)
39-
✔ [ 68] Text Justification Hard (18.95 %)
40-
✔ [ 57] Insert Interval Hard (27.46 %)
41-
✔ [ 44] Wildcard Matching Hard (19.93 %)
42-
✔ [ 25] Reverse Nodes in k-Group Hard (30.61 %)
43-
✔ [ 23] Merge k Sorted Lists Hard (27.08 %)
44-
✔ [ 10] Regular Expression Matching Hard (24.06 %)
45-
46-
### cpp.lint
47-
48-
Run cpplint to check c++ code syntax before running test.
49-
50-
$ leetcode test 1.two-sum.cpp
51-
52-
Input data:
53-
[3,2,4]
54-
6
55-
56-
Running cpplint ...
57-
58-
[ERROR] 1.two-sum.cpp:29: public: should be indented +1 space inside class Solution [whitespace/indent] [3]
59-
[ERROR] 1.two-sum.cpp:30: Is this a non-const reference? If so, make const or use a pointer: vector<int>& nums [runtime/references] [2]
60-
[ERROR] 1.two-sum.cpp:31: Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
61-
[ERROR] 1.two-sum.cpp:31: Redundant blank line at the start of a code block should be deleted. [whitespace/blank_line] [2]
62-
[ERROR] 1.two-sum.cpp:31: Redundant blank line at the end of a code block should be deleted. [whitespace/blank_line] [3]
63-
64-
65-
### cpp.run
66-
67-
* use `test` + `--local` to test your code locally without asking leetcode.com.
68-
69-
Testing cpp code locally for debugging purpose.
70-
71-
$ leetcode test 001.two-sum.cpp --local
72-
73-
Input data:
74-
[3,2,4]
75-
6
76-
77-
Testing locally ...
78-
79-
[1,2]
80-
81-
### solution.discuss
82-
83-
* use `show` + `--solution` to display most voted solution.
84-
* `-l java` to fetch java solution.
85-
86-
Fetch the most voted solution in discussion topics.
87-
88-
$ leetcode show 1 --solution
89-
90-
Accepted C++ O(n) Solution
91-
92-
https://discuss.leetcode.com/topic/3294/accepted-c-o-n-solution
93-
94-
* Lang: cpp
95-
* Votes: 221
96-
97-
vector<int> twoSum(vector<int> &numbers, int target)
98-
{
99-
//Key is the number and value is its index in the vector.
100-
unordered_map<int, int> hash;
101-
vector<int> result;
102-
for (int i = 0; i < numbers.size(); i++) {
103-
int numberToFind = target - numbers[i];
104-
105-
//if numberToFind is found in map, return them
106-
if (hash.find(numberToFind) != hash.end()) {
107-
//+1 because indices are NOT zero based
108-
result.push_back(hash[numberToFind] + 1);
109-
result.push_back(i + 1);
110-
return result;
111-
}
112-
113-
//number was not found. Put it in the map.
114-
hash[numbers[i]] = i;
115-
}
116-
return result;
117-
}
17+
To manage the installed plugins, please check [leetcode-cli's user guide](https://skygragon.github.io/leetcode-cli/commands#plugin).

docs/company.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Company
2+
3+
Filter questions by company name.
4+
5+
* `list` + `-t` to filter by company name.
6+
7+
## Usage
8+
9+
$ leetcode list -q hL -t facebook
10+
11+
[410] Split Array Largest Sum Hard (36.60 %)
12+
✔ [301] Remove Invalid Parentheses Hard (35.03 %)
13+
✔ [297] Serialize and Deserialize Binary Tree Hard (33.12 %)
14+
[282] Expression Add Operators Hard (29.55 %)
15+
[273] Integer to English Words Hard (21.98 %)
16+
[218] The Skyline Problem Hard (27.00 %)
17+
✔ [146] LRU Cache Hard (17.53 %)
18+
✔ [128] Longest Consecutive Sequence Hard (36.63 %)
19+
✔ [ 85] Maximal Rectangle Hard (27.66 %)
20+
✔ [ 76] Minimum Window Substring Hard (25.14 %)
21+
✔ [ 68] Text Justification Hard (18.95 %)
22+
✔ [ 57] Insert Interval Hard (27.46 %)
23+
✔ [ 44] Wildcard Matching Hard (19.93 %)
24+
✔ [ 25] Reverse Nodes in k-Group Hard (30.61 %)
25+
✔ [ 23] Merge k Sorted Lists Hard (27.08 %)
26+
✔ [ 10] Regular Expression Matching Hard (24.06 %)

docs/cpp.lint.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# cpp.lint
2+
3+
Run cpplint to check c++ code syntax before running `test` against leetcode.com.
4+
5+
## Requirement
6+
7+
* `cpplint.py`: [download](https://raw.githubusercontent.com/google/styleguide/gh-pages/cpplint/cpplint.py)
8+
9+
## Config
10+
11+
* `bin`: path of cpplint.py.
12+
* `flags`: list to enable/disable checking options.
13+
* `+` to enable specific checking.
14+
* `-` to disable specific checking.
15+
16+
*Example*
17+
18+
{
19+
"PLUGINS": {
20+
"cpp.lint": {
21+
"bin": "<path of cpplint script>",
22+
"flags": [
23+
"-whitespace/indent"
24+
]
25+
}
26+
}
27+
}
28+
29+
## Usage
30+
31+
$ leetcode test 1.two-sum.cpp
32+
33+
Input data:
34+
[3,2,4]
35+
6
36+
37+
Running cpplint ...
38+
39+
[ERROR] 1.two-sum.cpp:29: public: should be indented +1 space inside class Solution [whitespace/indent] [3]
40+
[ERROR] 1.two-sum.cpp:30: Is this a non-const reference? If so, make const or use a pointer: vector<int>& nums [runtime/references] [2]
41+
[ERROR] 1.two-sum.cpp:31: Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
42+
[ERROR] 1.two-sum.cpp:31: Redundant blank line at the start of a code block should be deleted. [whitespace/blank_line] [2]
43+
[ERROR] 1.two-sum.cpp:31: Redundant blank line at the end of a code block should be deleted. [whitespace/blank_line] [3]

docs/cpp.run.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# cpp.run
2+
3+
Testing cpp code locally for debugging purpose.
4+
5+
The `test` will run on your computer locally without aksing leetcode.com.
6+
7+
* `test` + `--local` to run local test.
8+
9+
NOTE: not fully support all the questions!
10+
11+
## Requirement
12+
13+
* `g++` with c++11 support.
14+
15+
## Usage
16+
17+
$ leetcode test 001.two-sum.cpp --local
18+
19+
Input data:
20+
[3,2,4]
21+
6
22+
23+
Testing locally ...
24+
25+
[1,2]

docs/github.md

Whitespace-only changes.

docs/lintcode.md

Whitespace-only changes.

docs/solution.discuss.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# solution.discuss
2+
3+
Fetch the most voted solution in discussion topics.
4+
5+
* `show` + `--solution` to display most voted solution.
6+
* `-l java` to fetch java solution.
7+
8+
## Usage
9+
10+
$ leetcode show 1 --solution
11+
12+
Accepted C++ O(n) Solution
13+
14+
https://discuss.leetcode.com/topic/3294/accepted-c-o-n-solution
15+
16+
* Lang: cpp
17+
* Votes: 221
18+
19+
vector<int> twoSum(vector<int> &numbers, int target)
20+
{
21+
//Key is the number and value is its index in the vector.
22+
unordered_map<int, int> hash;
23+
vector<int> result;
24+
for (int i = 0; i < numbers.size(); i++) {
25+
int numberToFind = target - numbers[i];
26+
27+
//if numberToFind is found in map, return them
28+
if (hash.find(numberToFind) != hash.end()) {
29+
//+1 because indices are NOT zero based
30+
result.push_back(hash[numberToFind] + 1);
31+
result.push_back(i + 1);
32+
return result;
33+
}
34+
35+
//number was not found. Put it in the map.
36+
hash[numbers[i]] = i;
37+
}
38+
return result;
39+
}

0 commit comments

Comments
 (0)