Skip to content

Commit 75b8f85

Browse files
committed
standardized question title
1 parent c28e1c0 commit 75b8f85

File tree

8 files changed

+84
-77
lines changed

8 files changed

+84
-77
lines changed

README.md

Lines changed: 39 additions & 39 deletions
Large diffs are not rendered by default.

ctl/models/mdrow.go

Lines changed: 4 additions & 3 deletions
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

Lines changed: 36 additions & 30 deletions
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/ChapterOne/Algorithm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ weight: 2
2323
|数论||1. 最大公约数<br> 2. 最小公倍数<br>3. 分解质因数<br>4. 素数判定<br>5. 进制转换<br>6. 高精度计算<br>7. 整除问题<br>8. 同余问题<br>9. 欧拉函数<br>10. 扩展欧几里得<br>11. 置换群<br>12. 母函数<br>13. 离散变换<br>14. 康托展开<br>15. 矩阵<br>16. 向量<br>17. 线性方程组<br>18. 线性规划<br> ||
2424
|几何||1. 凸包 - Gift wrapping<br>2. 凸包 - Graham scan<br>3. 线段问题<br> 4. 多边形和多面体相关问题<br>||
2525
|NP 完全|1. 计算模型<br>2. P 类与 NP 类问题<br>3. NP 完全问题<br>4. NP 完全问题的近似算法<br>|1. 随机存取机 RAM<br>2. 随机存取存储程序机 RASP<br>3. 图灵机<br>4. 非确定性图灵机<br>5. P 类与 NP 类语言<br>6. 多项式时间验证<br>7. 多项式时间变换<br>8. Cook定理<br>9. 合取范式的可满足性问题 CNF-SAT<br>10. 3 元合取范式的可满足性问题 3-SAT<br>11. 团问题 CLIQUE<br>12. 顶点覆盖问题 VERTEX-COVER<br>13. 子集和问题 SUBSET-SUM<br>14. 哈密顿回路问题 HAM-CYCLE<br>15. 旅行售货员问题 TSP<br>16. 顶点覆盖问题的近似算法<br>17. 旅行售货员问题近似算法<br>18. 具有三角不等式性质的旅行售货员问题<br>19. 一般的旅行售货员问题<br>20. 集合覆盖问题的近似算法<br>21. 子集和问题的近似算法<br>22. 子集和问题的指数时间算法<br>23. 子集和问题的多项式时间近似格式<br>||
26-
|位运算| 位操作包括:<br> 1. 取反(NOT)<br> 2. 按位或(OR) <br> 3. 按位异或(XOR) <br> 4. 按位与(AND) <br> 5. 移位: 是一个二元运算符,用来将一个二进制数中的每一位全部都向一个方向移动指定位,溢出的部分将被舍弃,而空缺的部分填入一定的值。<br> | 1.数字范围按位与<br> 2.UTF-8 编码验证<br> 3.数字转换为十六进制数<br> 4.找出最长的超赞子字符串<br> 5.数组异或操作<br> 6.幂集<br> 7.位1的个数<br> 8.二进制表示中质数个计算置位<br> 9.子数组异或查询<br>| [力扣:位运算](https://leetcode-cn.com/tag/bit-manipulation/)
26+
|位运算| 位操作包括:<br> 1. 取反(NOT)<br> 2. 按位或(OR) <br> 3. 按位异或(XOR) <br> 4. 按位与(AND) <br> 5. 移位: 是一个二元运算符,用来将一个二进制数中的每一位全部都向一个方向移动指定位,溢出的部分将被舍弃,而空缺的部分填入一定的值。<br> | 1.数字范围按位与<br> 2.UTF-8 编码验证<br> 3.数字转换为十六进制数<br> 4.找出最长的超赞子字符串<br> 5.数组异或操作<br> 6.幂集<br> 7.位1的个数<br> 8.二进制表示中质数个计算置位<br> 9.子数组异或查询<br>| [力扣:位运算](https://leetcode-cn.com/tag/bit-manipulation/)|
2727
|------------|------------------------------------------------------------------|-----------------------------------------------------------------|--------------------|
2828

2929

website/content/ChapterTwo/Binary_Indexed_Tree.md

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)