Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update: relative path #747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
awesee merged 1 commit into master from develop
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
60 changes: 30 additions & 30 deletions README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,44 @@ LeetCode Problems' Solutions

<table><thead>
<tr>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/1-300.md#1">[1-50]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/1-300.md#51">[51-100]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/1-300.md#101">[101-150]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/1-300.md#151">[151-200]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/1-300.md#201">[201-250]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/1-300.md#251">[251-300]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/1-300.md#1">[1-50]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/1-300.md#51">[51-100]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/1-300.md#101">[101-150]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/1-300.md#151">[151-200]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/1-300.md#201">[201-250]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/1-300.md#251">[251-300]</a></th>
</tr>
<tr>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/301-600.md#301">[301-350]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/301-600.md#351">[351-400]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/301-600.md#401">[401-450]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/301-600.md#451">[451-500]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/301-600.md#501">[501-550]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/301-600.md#551">[551-600]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/301-600.md#301">[301-350]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/301-600.md#351">[351-400]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/301-600.md#401">[401-450]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/301-600.md#451">[451-500]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/301-600.md#501">[501-550]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/301-600.md#551">[551-600]</a></th>
</tr>
<tr>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/601-900.md#601">[601-650]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/601-900.md#651">[651-700]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/601-900.md#701">[701-750]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/601-900.md#751">[751-800]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/601-900.md#801">[801-850]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/readme/601-900.md#851">[851-900]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/601-900.md#601">[601-650]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/601-900.md#651">[651-700]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/601-900.md#701">[701-750]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/601-900.md#751">[751-800]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/601-900.md#801">[801-850]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/readme/601-900.md#851">[851-900]</a></th>
</tr>
<tr>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#950">[901-950]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1000">[951-1000]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1050">[1001-1050]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1100">[1051-1100]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1150">[1101-1150]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1200">[1151-1200]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#950">[901-950]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1000">[951-1000]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1050">[1001-1050]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1100">[1051-1100]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1150">[1101-1150]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1200">[1151-1200]</a></th>
</tr>
<tr>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1250">[1201-1250]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1300">[1251-1300]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1350">[1301-1350]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1400">[1351-1400]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1450">[1401-1450]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/blob/master/README.md#1500">[1451-1500]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1250">[1201-1250]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1300">[1251-1300]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1350">[1301-1350]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1400">[1351-1400]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1450">[1401-1450]</a></th>
<th align="center"><a href="https://github.com/openset/leetcode/tree/master/README.md#1500">[1451-1500]</a></th>
</tr>
</thead></table>

Expand Down
5 changes: 4 additions & 1 deletion internal/base/base.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import (
)

// CmdName - base.CmdName
const CmdName = "leetcode"
const (
CmdName = "leetcode"
URL = "https://github.com/openset/leetcode/tree/master"
)

// base var
var (
Expand Down
6 changes: 3 additions & 3 deletions internal/leetcode/question_data.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (question *questionType) getNavigation() string {
nav, pre, next := "\n%s\n%s\n%s\n", "< Previous", "Next >"
problems := ProblemsAll().StatStatusPairs
id := question.questionID()
format := `[%s](https://github.com/openset/leetcode/tree/master/problems/%s "%s")`
format := `[%s](../%s "%s")`
for i, problem := range problems {
if problem.Stat.QuestionID == id {
if i < len(problems)-1 {
Expand All @@ -193,7 +193,7 @@ func (question *questionType) getTopicTags() []byte {
if len(tags) > 0 {
buf.WriteString("\n### Related Topics\n")
}
format := " [[%s](https://github.com/openset/leetcode/tree/master/tag/%s/README.md)]\n"
format := " [[%s](../../tag/%s/README.md)]\n"
for _, tag := range tags {
buf.WriteString(fmt.Sprintf(format, tag.Name, tag.Slug))
}
Expand Down Expand Up @@ -249,7 +249,7 @@ func (question *questionType) getSimilarQuestion() []byte {
if len(sq) > 0 {
buf.WriteString("\n### Similar Questions\n")
}
format := " 1. [%s](https://github.com/openset/leetcode/tree/master/problems/%s)%s\n"
format := " 1. [%s](../%s)%s\n"
for _, q := range sq {
buf.WriteString(fmt.Sprintf(format, q.Title, q.TitleSlug, q.Difficulty.Str()))
}
Expand Down
6 changes: 3 additions & 3 deletions internal/leetcode/topic_tag.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ func (tag *TagType) SaveContents() {
})
var buf bytes.Buffer
buf.WriteString(authInfo("tag"))
buf.WriteString(fmt.Sprintf("\n## [话题分类](https://github.com/openset/leetcode/blob/master/tag/README.md) > %s\n\n", tag.name()))
buf.WriteString(fmt.Sprintf("\n## [话题分类](../README.md) > %s\n\n", tag.name()))
buf.WriteString("| # | 题名 | 标签 | 难度 |\n")
buf.WriteString("| :-: | - | - | :-: |\n")
format := "| %d | [%s](https://github.com/openset/leetcode/tree/master/problems/%s)%s | %s | %s |\n"
format := "| %d | [%s](../../problems/%s)%s | %s | %s |\n"
for _, question := range questions {
if question.TranslatedTitle == "" {
question.TranslatedTitle = question.Title
Expand Down Expand Up @@ -85,7 +85,7 @@ type ttQuestionType struct {

func (question *ttQuestionType) TagsStr() string {
var buf bytes.Buffer
format := "[[%s](https://github.com/openset/leetcode/tree/master/tag/%s/README.md)] "
format := "[[%s](../%s/README.md)] "
for _, tag := range question.TopicTags {
buf.WriteString(fmt.Sprintf(format, tag.name(), tag.Slug))
}
Expand Down
3 changes: 2 additions & 1 deletion internal/open/open.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package open

import (
"fmt"
"strconv"

"github.com/openset/leetcode/internal/base"
Expand Down Expand Up @@ -31,7 +32,7 @@ func runOpen(cmd *base.Command, args []string) {
for _, problem := range problems.StatStatusPairs {
if problem.Stat.FrontendQuestionID == id {
titleSlug := problem.Stat.QuestionTitleSlug
browser.Open("https://github.com/openset/leetcode/tree/master/problems/" + titleSlug)
browser.Open(fmt.Sprintf("%s/problems/%s", base.URL, titleSlug))
break
}
}
Expand Down
6 changes: 3 additions & 3 deletions internal/post/post.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func runPost(cmd *base.Command, args []string) {
return
}
formatFilename := "%s-%s.md"
formatTopicTag := " [[%s](https://github.com/openset/leetcode/tree/master/tag/%s/README.md)]\n"
formatTopicTag := " [[%s](%s/tag/%s/README.md)]\n"
formatSimilarQuestion := " 1. [%s](/problems/%s)%s\n"
problems := leetcode.ProblemsAll()
for _, problem := range problems.StatStatusPairs {
Expand All @@ -71,7 +71,7 @@ func runPost(cmd *base.Command, args []string) {
if tag.TranslatedName != "" {
tag.Name = tag.TranslatedName
}
tagsBuf.WriteString(fmt.Sprintf(formatTopicTag, tag.Name, tag.Slug))
tagsBuf.WriteString(fmt.Sprintf(formatTopicTag, tag.Name, base.URL, tag.Slug))
}
buf.WriteString(fmt.Sprintf(frontMatter,
question.TranslatedTitle,
Expand Down Expand Up @@ -104,7 +104,7 @@ func runPost(cmd *base.Command, args []string) {
buf.WriteString(fmt.Sprintf(formatSimilarQuestion, q.Title, q.TitleSlug, q.Difficulty.Str()))
}
buf.WriteString("\n---\n")
buf.WriteString(fmt.Sprintf("\n## [解法](https://github.com/openset/leetcode/tree/master/problems/%s)\n", question.TitleSlug))
buf.WriteString(fmt.Sprintf("\n## [解法](%s/problems/%s)\n", base.URL, question.TitleSlug))
filename := fmt.Sprintf(formatFilename, t.Format("2006年01月02日"), question.TitleSlug)
oldPath := filepath.Join(basePath, "leetcode", filename)
newPath := filepath.Join(basePath, "_posts", filename)
Expand Down
5 changes: 2 additions & 3 deletions internal/readme/readme.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ func writeNav(buf *bytes.Buffer) {
}

func linkStr(num int) string {
link := "https://github.com/openset/leetcode/blob/master/"
if num > maxID-maxID%pageSize-pageSize {
return fmt.Sprintf("%sREADME.md#%d", link, num)
return fmt.Sprintf("%s/README.md#%d", base.URL, num)
}
return fmt.Sprintf("%sreadme/%d-%d.md#%d", link, (num-1)/pageSize*pageSize+1, ((num-1)/pageSize+1)*pageSize, num-step+1)
return fmt.Sprintf("%s/readme/%d-%d.md#%d", base.URL, (num-1)/pageSize*pageSize+1, ((num-1)/pageSize+1)*pageSize, num-step+1)
}
2 changes: 1 addition & 1 deletion internal/tag/tag.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func runTag(cmd *base.Command, args []string) {
buf.WriteString("\n## 话题分类\n\n")
buf.WriteString("| # | Title | 话题 | | # | Title | 话题 |\n")
buf.WriteString("| :-: | - | :-: | - | :-: | - | :-: |\n")
format := "| %d | [%s](https://github.com/openset/leetcode/tree/master/tag/%s/README.md) | [%s](https://openset.github.io/tags/%s/) | "
format := "| %d | [%s](%s/README.md) | [%s](https://openset.github.io/tags/%s/) | "
n := buf.Len()
for times := 0; times < 2; times++ {
buf.Truncate(n)
Expand Down
8 changes: 4 additions & 4 deletions problems/01-matrix/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

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

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

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

Expand Down Expand Up @@ -56,5 +56,5 @@
</ol>

### Related Topics
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
[[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)]
[[Depth-first Search](../../tag/depth-first-search/README.md)]
[[Breadth-first Search](../../tag/breadth-first-search/README.md)]
8 changes: 4 additions & 4 deletions problems/1-bit-and-2-bit-characters/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

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

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

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

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

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

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

### Hints
<details>
Expand Down
6 changes: 3 additions & 3 deletions problems/132-pattern/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

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

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

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

Expand Down Expand Up @@ -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
</p>

### Related Topics
[[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)]
[[Stack](../../tag/stack/README.md)]
10 changes: 5 additions & 5 deletions problems/2-keys-keyboard/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

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

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

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

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

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

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

### Hints
<details>
Expand Down
6 changes: 3 additions & 3 deletions problems/24-game/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

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

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

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

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

### Related Topics
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
[[Depth-first Search](../../tag/depth-first-search/README.md)]
12 changes: 6 additions & 6 deletions problems/3sum-closest/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

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

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

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

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

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

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

AltStyle によって変換されたページ (->オリジナル) /