Skip to content

Commit b012a1f

Browse files
committed
standardized question title
1 parent c28e1c0 commit b012a1f

File tree

7 files changed

+83
-76
lines changed

7 files changed

+83
-76
lines changed

README.md

+39-39
Large diffs are not rendered by default.

ctl/models/mdrow.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ func GenerateMdRows(solutionIds []int, mdrows []Mdrow) {
2424
}
2525
for i := 0; i < len(solutionIds); i++ {
2626
if row, ok := mdMap[solutionIds[i]]; ok {
27+
s7 := standardizedTitle(row.QuestionTitle, row.FrontendQuestionID)
2728
mdMap[solutionIds[i]] = Mdrow{
2829
FrontendQuestionID: row.FrontendQuestionID,
29-
QuestionTitle: row.QuestionTitle,
30+
QuestionTitle: strings.TrimSpace(row.QuestionTitle),
3031
QuestionTitleSlug: row.QuestionTitleSlug,
31-
SolutionPath: fmt.Sprintf("[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/%v)", fmt.Sprintf("%04d.%v", solutionIds[i], strings.Replace(strings.TrimSpace(row.QuestionTitle), " ", "-", -1))),
32+
SolutionPath: fmt.Sprintf("[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/%v)", fmt.Sprintf("%04d.%v", solutionIds[i], s7)),
3233
Acceptance: row.Acceptance,
3334
Difficulty: row.Difficulty,
3435
Frequency: row.Frequency,
@@ -40,7 +41,7 @@ func GenerateMdRows(solutionIds []int, mdrows []Mdrow) {
4041
for i := range mdrows {
4142
mdrows[i] = Mdrow{
4243
FrontendQuestionID: mdrows[i].FrontendQuestionID,
43-
QuestionTitle: mdrows[i].QuestionTitle,
44+
QuestionTitle: strings.TrimSpace(mdrows[i].QuestionTitle),
4445
QuestionTitleSlug: mdrows[i].QuestionTitleSlug,
4546
SolutionPath: mdMap[int(mdrows[i].FrontendQuestionID)].SolutionPath,
4647
Acceptance: mdrows[i].Acceptance,

ctl/models/tagproblem.go

+36-30
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,41 @@ func (t TagList) tableLine() string {
115115
return fmt.Sprintf("|%04d|%v|%v|%v|%v|%v|%v|%v|\n", t.FrontendQuestionID, t.QuestionTitle, t.SolutionPath, t.Difficulty, t.TimeComplexity, t.SpaceComplexity, t.Favorite, t.Acceptance)
116116
}
117117

118+
func standardizedTitle(orig string, frontendQuestionID int32) string {
119+
s0 := strings.TrimSpace(orig)
120+
s1 := strings.Replace(s0, " ", "-", -1)
121+
s2 := strings.Replace(s1, "'", "", -1)
122+
s3 := strings.Replace(s2, "%", "", -1)
123+
s4 := strings.Replace(s3, "(", "", -1)
124+
s5 := strings.Replace(s4, ")", "", -1)
125+
s6 := strings.Replace(s5, ",", "", -1)
126+
s7 := strings.Replace(s6, "?", "", -1)
127+
count := 0
128+
// 去掉 --- 这种情况,这种情况是由于题目标题中包含 - ,左右有空格,左右一填充,造成了 ---,3 个 -
129+
for i := 0; i < len(s7)-2; i++ {
130+
if s7[i] == '-' && s7[i+1] == '-' && s7[i+2] == '-' {
131+
fmt.Printf("【需要修正 --- 的标题是 %v】\n", fmt.Sprintf("%04d.%v", int(frontendQuestionID), s7))
132+
s7 = s7[:i+1] + s7[i+3:]
133+
count++
134+
}
135+
}
136+
if count > 0 {
137+
fmt.Printf("总共修正了 %v 个标题\n", count)
138+
}
139+
// 去掉 -- 这种情况,这种情况是由于题目标题中包含负号 -
140+
for i := 0; i < len(s7)-2; i++ {
141+
if s7[i] == '-' && s7[i+1] == '-' {
142+
fmt.Printf("【需要修正 -- 的标题是 %v】\n", fmt.Sprintf("%04d.%v", int(frontendQuestionID), s7))
143+
s7 = s7[:i+1] + s7[i+2:]
144+
count++
145+
}
146+
}
147+
if count > 0 {
148+
fmt.Printf("总共修正了 %v 个标题\n", count)
149+
}
150+
return s7
151+
}
152+
118153
// GenerateTagMdRows define
119154
func GenerateTagMdRows(solutionIds []int, metaMap map[int]TagList, mdrows []Mdrow, internal bool) []TagList {
120155
tl := []TagList{}
@@ -123,36 +158,7 @@ func GenerateTagMdRows(solutionIds []int, metaMap map[int]TagList, mdrows []Mdro
123158
tmp := TagList{}
124159
tmp.FrontendQuestionID = row.FrontendQuestionID
125160
tmp.QuestionTitle = strings.TrimSpace(row.QuestionTitle)
126-
s1 := strings.Replace(tmp.QuestionTitle, " ", "-", -1)
127-
s2 := strings.Replace(s1, "'", "", -1)
128-
s3 := strings.Replace(s2, "%", "", -1)
129-
s4 := strings.Replace(s3, "(", "", -1)
130-
s5 := strings.Replace(s4, ")", "", -1)
131-
s6 := strings.Replace(s5, ",", "", -1)
132-
s7 := strings.Replace(s6, "?", "", -1)
133-
count := 0
134-
// 去掉 --- 这种情况,这种情况是由于题目标题中包含 - ,左右有空格,左右一填充,造成了 ---,3 个 -
135-
for i := 0; i < len(s7)-2; i++ {
136-
if s7[i] == '-' && s7[i+1] == '-' && s7[i+2] == '-' {
137-
fmt.Printf("【需要修正 --- 的标题是 %v】\n", fmt.Sprintf("%04d.%v", int(row.FrontendQuestionID), s7))
138-
s7 = s7[:i+1] + s7[i+3:]
139-
count++
140-
}
141-
}
142-
if count > 0 {
143-
fmt.Printf("总共修正了 %v 个标题\n", count)
144-
}
145-
// 去掉 -- 这种情况,这种情况是由于题目标题中包含负号 -
146-
for i := 0; i < len(s7)-2; i++ {
147-
if s7[i] == '-' && s7[i+1] == '-' {
148-
fmt.Printf("【需要修正 -- 的标题是 %v】\n", fmt.Sprintf("%04d.%v", int(row.FrontendQuestionID), s7))
149-
s7 = s7[:i+1] + s7[i+2:]
150-
count++
151-
}
152-
}
153-
if count > 0 {
154-
fmt.Printf("总共修正了 %v 个标题\n", count)
155-
}
161+
s7 := standardizedTitle(row.QuestionTitle, row.FrontendQuestionID)
156162
if internal {
157163
tmp.SolutionPath = fmt.Sprintf("[Go]({{< relref \"/ChapterFour/%v/%v.md\" >}})", util.GetChpaterFourFileNum(int(row.FrontendQuestionID)), fmt.Sprintf("%04d.%v", int(row.FrontendQuestionID), s7))
158164
} else {

website/content/ChapterTwo/Binary_Indexed_Tree.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ weight: 19
1111
| No. | Title | Solution | Difficulty | TimeComplexity | SpaceComplexity |Favorite| Acceptance |
1212
|:--------:|:------- | :--------: | :----------: | :----: | :-----: | :-----: |:-----: |
1313
|0218|The Skyline Problem|[Go]({{< relref "/ChapterFour/0200~0299/0218.The-Skyline-Problem.md" >}})|Hard||||37.1%|
14-
|0307|Range Sum Query - Mutable|[Go]({{< relref "/ChapterFour/0300~0399/0307.Range-Sum-Query-Mutable.md" >}})|Medium||||37.6%|
14+
|0307|Range Sum Query - Mutable|[Go]({{< relref "/ChapterFour/0300~0399/0307.Range-Sum-Query-Mutable.md" >}})|Medium||||37.7%|
1515
|0315|Count of Smaller Numbers After Self|[Go]({{< relref "/ChapterFour/0300~0399/0315.Count-of-Smaller-Numbers-After-Self.md" >}})|Hard||||42.3%|
1616
|0327|Count of Range Sum|[Go]({{< relref "/ChapterFour/0300~0399/0327.Count-of-Range-Sum.md" >}})|Hard||||36.3%|
1717
|0493|Reverse Pairs|[Go]({{< relref "/ChapterFour/0400~0499/0493.Reverse-Pairs.md" >}})|Hard||||27.7%|

website/content/ChapterTwo/Breadth_First_Search.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ weight: 10
2828
|0529|Minesweeper|[Go]({{< relref "/ChapterFour/0500~0599/0529.Minesweeper.md" >}})|Medium||||62.1%|
2929
|0542|01 Matrix|[Go]({{< relref "/ChapterFour/0500~0599/0542.01-Matrix.md" >}})|Medium| O(n)| O(1)||41.5%|
3030
|0690|Employee Importance|[Go]({{< relref "/ChapterFour/0600~0699/0690.Employee-Importance.md" >}})|Easy||||59.8%|
31-
|0785|Is Graph Bipartite?|[Go]({{< relref "/ChapterFour/0700~0799/0785.Is-Graph-Bipartite.md" >}})|Medium||||49.1%|
31+
|0785|Is Graph Bipartite?|[Go]({{< relref "/ChapterFour/0700~0799/0785.Is-Graph-Bipartite.md" >}})|Medium||||49.0%|
3232
|0815|Bus Routes|[Go]({{< relref "/ChapterFour/0800~0899/0815.Bus-Routes.md" >}})|Hard||||43.8%|
3333
|0863|All Nodes Distance K in Binary Tree|[Go]({{< relref "/ChapterFour/0800~0899/0863.All-Nodes-Distance-K-in-Binary-Tree.md" >}})|Medium||||58.7%|
3434
|0864|Shortest Path to Get All Keys|[Go]({{< relref "/ChapterFour/0800~0899/0864.Shortest-Path-to-Get-All-Keys.md" >}})|Hard||||42.8%|

website/content/ChapterTwo/Depth_First_Search.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ weight: 9
5959
|0756|Pyramid Transition Matrix|[Go]({{< relref "/ChapterFour/0700~0799/0756.Pyramid-Transition-Matrix.md" >}})|Medium||||55.9%|
6060
|0778|Swim in Rising Water|[Go]({{< relref "/ChapterFour/0700~0799/0778.Swim-in-Rising-Water.md" >}})|Hard||||55.3%|
6161
|0783|Minimum Distance Between BST Nodes|[Go]({{< relref "/ChapterFour/0700~0799/0783.Minimum-Distance-Between-BST-Nodes.md" >}})|Easy||||54.6%|
62-
|0785|Is Graph Bipartite?|[Go]({{< relref "/ChapterFour/0700~0799/0785.Is-Graph-Bipartite.md" >}})|Medium||||49.1%|
62+
|0785|Is Graph Bipartite?|[Go]({{< relref "/ChapterFour/0700~0799/0785.Is-Graph-Bipartite.md" >}})|Medium||||49.0%|
6363
|0802|Find Eventual Safe States|[Go]({{< relref "/ChapterFour/0800~0899/0802.Find-Eventual-Safe-States.md" >}})|Medium||||50.5%|
6464
|0834|Sum of Distances in Tree|[Go]({{< relref "/ChapterFour/0800~0899/0834.Sum-of-Distances-in-Tree.md" >}})|Hard||||47.3%|
6565
|0839|Similar String Groups|[Go]({{< relref "/ChapterFour/0800~0899/0839.Similar-String-Groups.md" >}})|Hard||||42.6%|

website/content/ChapterTwo/Segment_Tree.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ weight: 18
3838
| No. | Title | Solution | Difficulty | TimeComplexity | SpaceComplexity |Favorite| Acceptance |
3939
|:--------:|:------- | :--------: | :----------: | :----: | :-----: | :-----: |:-----: |
4040
|0218|The Skyline Problem|[Go]({{< relref "/ChapterFour/0200~0299/0218.The-Skyline-Problem.md" >}})|Hard| O(n log n)| O(n)|❤️|37.1%|
41-
|0307|Range Sum Query - Mutable|[Go]({{< relref "/ChapterFour/0300~0399/0307.Range-Sum-Query-Mutable.md" >}})|Medium| O(1)| O(n)||37.6%|
41+
|0307|Range Sum Query - Mutable|[Go]({{< relref "/ChapterFour/0300~0399/0307.Range-Sum-Query-Mutable.md" >}})|Medium| O(1)| O(n)||37.7%|
4242
|0315|Count of Smaller Numbers After Self|[Go]({{< relref "/ChapterFour/0300~0399/0315.Count-of-Smaller-Numbers-After-Self.md" >}})|Hard| O(n log n)| O(n)||42.3%|
4343
|0327|Count of Range Sum|[Go]({{< relref "/ChapterFour/0300~0399/0327.Count-of-Range-Sum.md" >}})|Hard| O(n log n)| O(n)|❤️|36.3%|
4444
|0493|Reverse Pairs|[Go]({{< relref "/ChapterFour/0400~0499/0493.Reverse-Pairs.md" >}})|Hard| O(n log n)| O(n)||27.7%|

0 commit comments

Comments
 (0)