Skip to content

Commit 08c1f39

Browse files
author
Shuo
authored
Merge pull request #747 from openset/develop
Update: relative path
2 parents abb1663 + cabf520 commit 08c1f39

File tree

1,345 files changed

+7701
-7698
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,345 files changed

+7701
-7698
lines changed

README.md

+30-30
Original file line numberDiff line numberDiff line change
@@ -19,44 +19,44 @@ LeetCode Problems' Solutions
1919

2020
<table><thead>
2121
<tr>
22-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/1-300.md#1">[1-50]</a></th>
23-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/1-300.md#51">[51-100]</a></th>
24-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/1-300.md#101">[101-150]</a></th>
25-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/1-300.md#151">[151-200]</a></th>
26-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/1-300.md#201">[201-250]</a></th>
27-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/1-300.md#251">[251-300]</a></th>
22+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/1-300.md#1">[1-50]</a></th>
23+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/1-300.md#51">[51-100]</a></th>
24+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/1-300.md#101">[101-150]</a></th>
25+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/1-300.md#151">[151-200]</a></th>
26+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/1-300.md#201">[201-250]</a></th>
27+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/1-300.md#251">[251-300]</a></th>
2828
</tr>
2929
<tr>
30-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/301-600.md#301">[301-350]</a></th>
31-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/301-600.md#351">[351-400]</a></th>
32-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/301-600.md#401">[401-450]</a></th>
33-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/301-600.md#451">[451-500]</a></th>
34-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/301-600.md#501">[501-550]</a></th>
35-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/301-600.md#551">[551-600]</a></th>
30+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/301-600.md#301">[301-350]</a></th>
31+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/301-600.md#351">[351-400]</a></th>
32+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/301-600.md#401">[401-450]</a></th>
33+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/301-600.md#451">[451-500]</a></th>
34+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/301-600.md#501">[501-550]</a></th>
35+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/301-600.md#551">[551-600]</a></th>
3636
</tr>
3737
<tr>
38-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/601-900.md#601">[601-650]</a></th>
39-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/601-900.md#651">[651-700]</a></th>
40-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/601-900.md#701">[701-750]</a></th>
41-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/601-900.md#751">[751-800]</a></th>
42-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/601-900.md#801">[801-850]</a></th>
43-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/601-900.md#851">[851-900]</a></th>
38+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/601-900.md#601">[601-650]</a></th>
39+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/601-900.md#651">[651-700]</a></th>
40+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/601-900.md#701">[701-750]</a></th>
41+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/601-900.md#751">[751-800]</a></th>
42+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/601-900.md#801">[801-850]</a></th>
43+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/601-900.md#851">[851-900]</a></th>
4444
</tr>
4545
<tr>
46-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#950">[901-950]</a></th>
47-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1000">[951-1000]</a></th>
48-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1050">[1001-1050]</a></th>
49-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1100">[1051-1100]</a></th>
50-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1150">[1101-1150]</a></th>
51-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1200">[1151-1200]</a></th>
46+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#950">[901-950]</a></th>
47+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1000">[951-1000]</a></th>
48+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1050">[1001-1050]</a></th>
49+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1100">[1051-1100]</a></th>
50+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1150">[1101-1150]</a></th>
51+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1200">[1151-1200]</a></th>
5252
</tr>
5353
<tr>
54-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1250">[1201-1250]</a></th>
55-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1300">[1251-1300]</a></th>
56-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1350">[1301-1350]</a></th>
57-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1400">[1351-1400]</a></th>
58-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1450">[1401-1450]</a></th>
59-
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1500">[1451-1500]</a></th>
54+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1250">[1201-1250]</a></th>
55+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1300">[1251-1300]</a></th>
56+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1350">[1301-1350]</a></th>
57+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1400">[1351-1400]</a></th>
58+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1450">[1401-1450]</a></th>
59+
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1500">[1451-1500]</a></th>
6060
</tr>
6161
</thead></table>
6262

internal/base/base.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import (
1414
)
1515

1616
// CmdName - base.CmdName
17-
const CmdName = "leetcode"
17+
const (
18+
CmdName = "leetcode"
19+
URL = "https://github.com/openset/leetcode/tree/master"
20+
)
1821

1922
// base var
2023
var (

internal/leetcode/question_data.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (question *questionType) getNavigation() string {
172172
nav, pre, next := "\n%s\n%s\n%s\n", "< Previous", "Next >"
173173
problems := ProblemsAll().StatStatusPairs
174174
id := question.questionID()
175-
format := `[%s](https://github.com/openset/leetcode/tree/master/problems/%s "%s")`
175+
format := `[%s](../%s "%s")`
176176
for i, problem := range problems {
177177
if problem.Stat.QuestionID == id {
178178
if i < len(problems)-1 {
@@ -193,7 +193,7 @@ func (question *questionType) getTopicTags() []byte {
193193
if len(tags) > 0 {
194194
buf.WriteString("\n### Related Topics\n")
195195
}
196-
format := " [[%s](https://github.com/openset/leetcode/tree/master/tag/%s/README.md)]\n"
196+
format := " [[%s](../../tag/%s/README.md)]\n"
197197
for _, tag := range tags {
198198
buf.WriteString(fmt.Sprintf(format, tag.Name, tag.Slug))
199199
}
@@ -249,7 +249,7 @@ func (question *questionType) getSimilarQuestion() []byte {
249249
if len(sq) > 0 {
250250
buf.WriteString("\n### Similar Questions\n")
251251
}
252-
format := " 1. [%s](https://github.com/openset/leetcode/tree/master/problems/%s)%s\n"
252+
format := " 1. [%s](../%s)%s\n"
253253
for _, q := range sq {
254254
buf.WriteString(fmt.Sprintf(format, q.Title, q.TitleSlug, q.Difficulty.Str()))
255255
}

internal/leetcode/topic_tag.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ func (tag *TagType) SaveContents() {
3434
})
3535
var buf bytes.Buffer
3636
buf.WriteString(authInfo("tag"))
37-
buf.WriteString(fmt.Sprintf("\n## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > %s\n\n", tag.name()))
37+
buf.WriteString(fmt.Sprintf("\n## [话题分类](../README.md) > %s\n\n", tag.name()))
3838
buf.WriteString("| # | 题名 | 标签 | 难度 |\n")
3939
buf.WriteString("| :-: | - | - | :-: |\n")
40-
format := "| %d | [%s](https://github.com/openset/leetcode/tree/master/problems/%s)%s | %s | %s |\n"
40+
format := "| %d | [%s](../../problems/%s)%s | %s | %s |\n"
4141
for _, question := range questions {
4242
if question.TranslatedTitle == "" {
4343
question.TranslatedTitle = question.Title
@@ -85,7 +85,7 @@ type ttQuestionType struct {
8585

8686
func (question *ttQuestionType) TagsStr() string {
8787
var buf bytes.Buffer
88-
format := "[[%s](https://github.com/openset/leetcode/tree/master/tag/%s/README.md)] "
88+
format := "[[%s](../%s/README.md)] "
8989
for _, tag := range question.TopicTags {
9090
buf.WriteString(fmt.Sprintf(format, tag.name(), tag.Slug))
9191
}

internal/open/open.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package open
33

44
import (
5+
"fmt"
56
"strconv"
67

78
"github.com/openset/leetcode/internal/base"
@@ -31,7 +32,7 @@ func runOpen(cmd *base.Command, args []string) {
3132
for _, problem := range problems.StatStatusPairs {
3233
if problem.Stat.FrontendQuestionID == id {
3334
titleSlug := problem.Stat.QuestionTitleSlug
34-
browser.Open("https://github.com/openset/leetcode/tree/master/problems/" + titleSlug)
35+
browser.Open(fmt.Sprintf("%s/problems/%s", base.URL, titleSlug))
3536
break
3637
}
3738
}

internal/post/post.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func runPost(cmd *base.Command, args []string) {
5252
return
5353
}
5454
formatFilename := "%s-%s.md"
55-
formatTopicTag := " [[%s](https://github.com/openset/leetcode/tree/master/tag/%s/README.md)]\n"
55+
formatTopicTag := " [[%s](%s/tag/%s/README.md)]\n"
5656
formatSimilarQuestion := " 1. [%s](/problems/%s)%s\n"
5757
problems := leetcode.ProblemsAll()
5858
for _, problem := range problems.StatStatusPairs {
@@ -71,7 +71,7 @@ func runPost(cmd *base.Command, args []string) {
7171
if tag.TranslatedName != "" {
7272
tag.Name = tag.TranslatedName
7373
}
74-
tagsBuf.WriteString(fmt.Sprintf(formatTopicTag, tag.Name, tag.Slug))
74+
tagsBuf.WriteString(fmt.Sprintf(formatTopicTag, tag.Name, base.URL, tag.Slug))
7575
}
7676
buf.WriteString(fmt.Sprintf(frontMatter,
7777
question.TranslatedTitle,
@@ -104,7 +104,7 @@ func runPost(cmd *base.Command, args []string) {
104104
buf.WriteString(fmt.Sprintf(formatSimilarQuestion, q.Title, q.TitleSlug, q.Difficulty.Str()))
105105
}
106106
buf.WriteString("\n---\n")
107-
buf.WriteString(fmt.Sprintf("\n## [解法](https://github.com/openset/leetcode/tree/master/problems/%s)\n", question.TitleSlug))
107+
buf.WriteString(fmt.Sprintf("\n## [解法](%s/problems/%s)\n", base.URL, question.TitleSlug))
108108
filename := fmt.Sprintf(formatFilename, t.Format("2006-01-02"), question.TitleSlug)
109109
oldPath := filepath.Join(basePath, "leetcode", filename)
110110
newPath := filepath.Join(basePath, "_posts", filename)

internal/readme/readme.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ func writeNav(buf *bytes.Buffer) {
9999
}
100100

101101
func linkStr(num int) string {
102-
link := "https://github.com/openset/leetcode/blob/master/"
103102
if num > maxID-maxID%pageSize-pageSize {
104-
return fmt.Sprintf("%sREADME.md#%d", link, num)
103+
return fmt.Sprintf("%s/README.md#%d", base.URL, num)
105104
}
106-
return fmt.Sprintf("%sreadme/%d-%d.md#%d", link, (num-1)/pageSize*pageSize+1, ((num-1)/pageSize+1)*pageSize, num-step+1)
105+
return fmt.Sprintf("%s/readme/%d-%d.md#%d", base.URL, (num-1)/pageSize*pageSize+1, ((num-1)/pageSize+1)*pageSize, num-step+1)
107106
}

internal/tag/tag.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func runTag(cmd *base.Command, args []string) {
3131
buf.WriteString("\n## 话题分类\n\n")
3232
buf.WriteString("| # | Title | 话题 | | # | Title | 话题 |\n")
3333
buf.WriteString("| :-: | - | :-: | - | :-: | - | :-: |\n")
34-
format := "| %d | [%s](https://github.com/openset/leetcode/tree/master/tag/%s/README.md) | [%s](https://openset.github.io/tags/%s/) | "
34+
format := "| %d | [%s](%s/README.md) | [%s](https://openset.github.io/tags/%s/) | "
3535
n := buf.Len()
3636
for times := 0; times < 2; times++ {
3737
buf.Truncate(n)

problems/01-matrix/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<!--|@home https://github.com/openset/leetcode |-->
66
<!--+----------------------------------------------------------------------+-->
77

8-
[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-string-ii "Reverse String II")
8+
[< Previous](../reverse-string-ii "Reverse String II")
99

10-
[Next >](https://github.com/openset/leetcode/tree/master/problems/diameter-of-binary-tree "Diameter of Binary Tree")
10+
[Next >](../diameter-of-binary-tree "Diameter of Binary Tree")
1111

1212
## [542. 01 Matrix (Medium)](https://leetcode.com/problems/01-matrix "01 矩阵")
1313

@@ -56,5 +56,5 @@
5656
</ol>
5757

5858
### Related Topics
59-
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
60-
[[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)]
59+
[[Depth-first Search](../../tag/depth-first-search/README.md)]
60+
[[Breadth-first Search](../../tag/breadth-first-search/README.md)]

problems/1-bit-and-2-bit-characters/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<!--|@home https://github.com/openset/leetcode |-->
66
<!--+----------------------------------------------------------------------+-->
77

8-
[< Previous](https://github.com/openset/leetcode/tree/master/problems/max-stack "Max Stack")
8+
[< Previous](../max-stack "Max Stack")
99

10-
[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-length-of-repeated-subarray "Maximum Length of Repeated Subarray")
10+
[Next >](../maximum-length-of-repeated-subarray "Maximum Length of Repeated Subarray")
1111

1212
## [717. 1-bit and 2-bit Characters (Easy)](https://leetcode.com/problems/1-bit-and-2-bit-characters "1比特与2比特字符")
1313

@@ -41,10 +41,10 @@ The only way to decode it is two-bit character and two-bit character. So the las
4141
</p>
4242

4343
### Related Topics
44-
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
44+
[[Array](../../tag/array/README.md)]
4545

4646
### Similar Questions
47-
1. [Gray Code](https://github.com/openset/leetcode/tree/master/problems/gray-code) (Medium)
47+
1. [Gray Code](../gray-code) (Medium)
4848

4949
### Hints
5050
<details>

problems/132-pattern/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<!--|@home https://github.com/openset/leetcode |-->
66
<!--+----------------------------------------------------------------------+-->
77

8-
[< Previous](https://github.com/openset/leetcode/tree/master/problems/assign-cookies "Assign Cookies")
8+
[< Previous](../assign-cookies "Assign Cookies")
99

10-
[Next >](https://github.com/openset/leetcode/tree/master/problems/circular-array-loop "Circular Array Loop")
10+
[Next >](../circular-array-loop "Circular Array Loop")
1111

1212
## [456. 132 Pattern (Medium)](https://leetcode.com/problems/132-pattern "132模式")
1313

@@ -48,4 +48,4 @@ that <b>i</b> < <b>j</b> < <b>k</b> and a<sub><b>i</b></sub> < a<sub><b>k</b></s
4848
</p>
4949

5050
### Related Topics
51-
[[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)]
51+
[[Stack](../../tag/stack/README.md)]

problems/2-keys-keyboard/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<!--|@home https://github.com/openset/leetcode |-->
66
<!--+----------------------------------------------------------------------+-->
77

8-
[< Previous](https://github.com/openset/leetcode/tree/master/problems/dota2-senate "Dota2 Senate")
8+
[< Previous](../dota2-senate "Dota2 Senate")
99

10-
[Next >](https://github.com/openset/leetcode/tree/master/problems/4-keys-keyboard "4 Keys Keyboard")
10+
[Next >](../4-keys-keyboard "4 Keys Keyboard")
1111

1212
## [650. 2 Keys Keyboard (Medium)](https://leetcode.com/problems/2-keys-keyboard "只有两个键的键盘")
1313

@@ -45,11 +45,11 @@ In step 3, we use <b>Paste</b> operation to get &#39;AAA&#39;.
4545
<p>&nbsp;</p>
4646

4747
### Related Topics
48-
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
48+
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]
4949

5050
### Similar Questions
51-
1. [4 Keys Keyboard](https://github.com/openset/leetcode/tree/master/problems/4-keys-keyboard) (Medium)
52-
1. [Broken Calculator](https://github.com/openset/leetcode/tree/master/problems/broken-calculator) (Medium)
51+
1. [4 Keys Keyboard](../4-keys-keyboard) (Medium)
52+
1. [Broken Calculator](../broken-calculator) (Medium)
5353

5454
### Hints
5555
<details>

problems/24-game/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<!--|@home https://github.com/openset/leetcode |-->
66
<!--+----------------------------------------------------------------------+-->
77

8-
[< Previous](https://github.com/openset/leetcode/tree/master/problems/valid-parenthesis-string "Valid Parenthesis String")
8+
[< Previous](../valid-parenthesis-string "Valid Parenthesis String")
99

10-
[Next >](https://github.com/openset/leetcode/tree/master/problems/valid-palindrome-ii "Valid Palindrome II")
10+
[Next >](../valid-palindrome-ii "Valid Palindrome II")
1111

1212
## [679. 24 Game (Hard)](https://leetcode.com/problems/24-game "24 点游戏")
1313

@@ -40,4 +40,4 @@ You have 4 cards each containing a number from 1 to 9. You need to judge whethe
4040
</p>
4141

4242
### Related Topics
43-
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
43+
[[Depth-first Search](../../tag/depth-first-search/README.md)]

problems/3sum-closest/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<!--|@home https://github.com/openset/leetcode |-->
66
<!--+----------------------------------------------------------------------+-->
77

8-
[< Previous](https://github.com/openset/leetcode/tree/master/problems/3sum "3Sum")
8+
[< Previous](../3sum "3Sum")
99

10-
[Next >](https://github.com/openset/leetcode/tree/master/problems/letter-combinations-of-a-phone-number "Letter Combinations of a Phone Number")
10+
[Next >](../letter-combinations-of-a-phone-number "Letter Combinations of a Phone Number")
1111

1212
## [16. 3Sum Closest (Medium)](https://leetcode.com/problems/3sum-closest "最接近的三数之和")
1313

@@ -22,9 +22,9 @@ The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).
2222
</pre>
2323

2424
### Related Topics
25-
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
26-
[[Two Pointers](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)]
25+
[[Array](../../tag/array/README.md)]
26+
[[Two Pointers](../../tag/two-pointers/README.md)]
2727

2828
### Similar Questions
29-
1. [3Sum](https://github.com/openset/leetcode/tree/master/problems/3sum) (Medium)
30-
1. [3Sum Smaller](https://github.com/openset/leetcode/tree/master/problems/3sum-smaller) (Medium)
29+
1. [3Sum](../3sum) (Medium)
30+
1. [3Sum Smaller](../3sum-smaller) (Medium)

0 commit comments

Comments
 (0)