Skip to content

Commit

Permalink
standardized question title
Browse files Browse the repository at this point in the history
  • Loading branch information
halfrost committed Jun 20, 2021
1 parent c28e1c0 commit b012a1f
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 76 deletions.
78 changes: 39 additions & 39 deletions README.md

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions ctl/models/mdrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ func GenerateMdRows(solutionIds []int, mdrows []Mdrow) {
}
for i := 0; i < len(solutionIds); i++ {
if row, ok := mdMap[solutionIds[i]]; ok {
s7 := standardizedTitle(row.QuestionTitle, row.FrontendQuestionID)
mdMap[solutionIds[i]] = Mdrow{
FrontendQuestionID: row.FrontendQuestionID,
QuestionTitle: row.QuestionTitle,
QuestionTitle: strings.TrimSpace(row.QuestionTitle),
QuestionTitleSlug: row.QuestionTitleSlug,
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))),
SolutionPath: fmt.Sprintf("[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/%v)", fmt.Sprintf("%04d.%v", solutionIds[i], s7)),
Acceptance: row.Acceptance,
Difficulty: row.Difficulty,
Frequency: row.Frequency,
Expand All @@ -40,7 +41,7 @@ func GenerateMdRows(solutionIds []int, mdrows []Mdrow) {
for i := range mdrows {
mdrows[i] = Mdrow{
FrontendQuestionID: mdrows[i].FrontendQuestionID,
QuestionTitle: mdrows[i].QuestionTitle,
QuestionTitle: strings.TrimSpace(mdrows[i].QuestionTitle),
QuestionTitleSlug: mdrows[i].QuestionTitleSlug,
SolutionPath: mdMap[int(mdrows[i].FrontendQuestionID)].SolutionPath,
Acceptance: mdrows[i].Acceptance,
Expand Down
66 changes: 36 additions & 30 deletions ctl/models/tagproblem.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,41 @@ func (t TagList) tableLine() string {
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)
}

func standardizedTitle(orig string, frontendQuestionID int32) string {
s0 := strings.TrimSpace(orig)
s1 := strings.Replace(s0, " ", "-", -1)
s2 := strings.Replace(s1, "'", "", -1)
s3 := strings.Replace(s2, "%", "", -1)
s4 := strings.Replace(s3, "(", "", -1)
s5 := strings.Replace(s4, ")", "", -1)
s6 := strings.Replace(s5, ",", "", -1)
s7 := strings.Replace(s6, "?", "", -1)
count := 0
// 去掉 --- 这种情况,这种情况是由于题目标题中包含 - ,左右有空格,左右一填充,造成了 ---,3 个 -
for i := 0; i < len(s7)-2; i++ {
if s7[i] == '-' && s7[i+1] == '-' && s7[i+2] == '-' {
fmt.Printf("【需要修正 --- 的标题是 %v】\n", fmt.Sprintf("%04d.%v", int(frontendQuestionID), s7))
s7 = s7[:i+1] + s7[i+3:]
count++
}
}
if count > 0 {
fmt.Printf("总共修正了 %v 个标题\n", count)
}
// 去掉 -- 这种情况,这种情况是由于题目标题中包含负号 -
for i := 0; i < len(s7)-2; i++ {
if s7[i] == '-' && s7[i+1] == '-' {
fmt.Printf("【需要修正 -- 的标题是 %v】\n", fmt.Sprintf("%04d.%v", int(frontendQuestionID), s7))
s7 = s7[:i+1] + s7[i+2:]
count++
}
}
if count > 0 {
fmt.Printf("总共修正了 %v 个标题\n", count)
}
return s7
}

// GenerateTagMdRows define
func GenerateTagMdRows(solutionIds []int, metaMap map[int]TagList, mdrows []Mdrow, internal bool) []TagList {
tl := []TagList{}
Expand All @@ -123,36 +158,7 @@ func GenerateTagMdRows(solutionIds []int, metaMap map[int]TagList, mdrows []Mdro
tmp := TagList{}
tmp.FrontendQuestionID = row.FrontendQuestionID
tmp.QuestionTitle = strings.TrimSpace(row.QuestionTitle)
s1 := strings.Replace(tmp.QuestionTitle, " ", "-", -1)
s2 := strings.Replace(s1, "'", "", -1)
s3 := strings.Replace(s2, "%", "", -1)
s4 := strings.Replace(s3, "(", "", -1)
s5 := strings.Replace(s4, ")", "", -1)
s6 := strings.Replace(s5, ",", "", -1)
s7 := strings.Replace(s6, "?", "", -1)
count := 0
// 去掉 --- 这种情况,这种情况是由于题目标题中包含 - ,左右有空格,左右一填充,造成了 ---,3 个 -
for i := 0; i < len(s7)-2; i++ {
if s7[i] == '-' && s7[i+1] == '-' && s7[i+2] == '-' {
fmt.Printf("【需要修正 --- 的标题是 %v】\n", fmt.Sprintf("%04d.%v", int(row.FrontendQuestionID), s7))
s7 = s7[:i+1] + s7[i+3:]
count++
}
}
if count > 0 {
fmt.Printf("总共修正了 %v 个标题\n", count)
}
// 去掉 -- 这种情况,这种情况是由于题目标题中包含负号 -
for i := 0; i < len(s7)-2; i++ {
if s7[i] == '-' && s7[i+1] == '-' {
fmt.Printf("【需要修正 -- 的标题是 %v】\n", fmt.Sprintf("%04d.%v", int(row.FrontendQuestionID), s7))
s7 = s7[:i+1] + s7[i+2:]
count++
}
}
if count > 0 {
fmt.Printf("总共修正了 %v 个标题\n", count)
}
s7 := standardizedTitle(row.QuestionTitle, row.FrontendQuestionID)
if internal {
tmp.SolutionPath = fmt.Sprintf("[Go]({{< relref \"/ChapterFour/%v/%v.md\" >}})", util.GetChpaterFourFileNum(int(row.FrontendQuestionID)), fmt.Sprintf("%04d.%v", int(row.FrontendQuestionID), s7))
} else {
Expand Down
2 changes: 1 addition & 1 deletion website/content/ChapterTwo/Binary_Indexed_Tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ weight: 19
| No. | Title | Solution | Difficulty | TimeComplexity | SpaceComplexity |Favorite| Acceptance |
|:--------:|:------- | :--------: | :----------: | :----: | :-----: | :-----: |:-----: |
|0218|The Skyline Problem|[Go]({{< relref "/ChapterFour/0200~0299/0218.The-Skyline-Problem.md" >}})|Hard||||37.1%|
|0307|Range Sum Query - Mutable|[Go]({{< relref "/ChapterFour/0300~0399/0307.Range-Sum-Query-Mutable.md" >}})|Medium||||37.6%|
|0307|Range Sum Query - Mutable|[Go]({{< relref "/ChapterFour/0300~0399/0307.Range-Sum-Query-Mutable.md" >}})|Medium||||37.7%|
|0315|Count of Smaller Numbers After Self|[Go]({{< relref "/ChapterFour/0300~0399/0315.Count-of-Smaller-Numbers-After-Self.md" >}})|Hard||||42.3%|
|0327|Count of Range Sum|[Go]({{< relref "/ChapterFour/0300~0399/0327.Count-of-Range-Sum.md" >}})|Hard||||36.3%|
|0493|Reverse Pairs|[Go]({{< relref "/ChapterFour/0400~0499/0493.Reverse-Pairs.md" >}})|Hard||||27.7%|
Expand Down
2 changes: 1 addition & 1 deletion website/content/ChapterTwo/Breadth_First_Search.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ weight: 10
|0529|Minesweeper|[Go]({{< relref "/ChapterFour/0500~0599/0529.Minesweeper.md" >}})|Medium||||62.1%|
|0542|01 Matrix|[Go]({{< relref "/ChapterFour/0500~0599/0542.01-Matrix.md" >}})|Medium| O(n)| O(1)||41.5%|
|0690|Employee Importance|[Go]({{< relref "/ChapterFour/0600~0699/0690.Employee-Importance.md" >}})|Easy||||59.8%|
|0785|Is Graph Bipartite?|[Go]({{< relref "/ChapterFour/0700~0799/0785.Is-Graph-Bipartite.md" >}})|Medium||||49.1%|
|0785|Is Graph Bipartite?|[Go]({{< relref "/ChapterFour/0700~0799/0785.Is-Graph-Bipartite.md" >}})|Medium||||49.0%|
|0815|Bus Routes|[Go]({{< relref "/ChapterFour/0800~0899/0815.Bus-Routes.md" >}})|Hard||||43.8%|
|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%|
|0864|Shortest Path to Get All Keys|[Go]({{< relref "/ChapterFour/0800~0899/0864.Shortest-Path-to-Get-All-Keys.md" >}})|Hard||||42.8%|
Expand Down
2 changes: 1 addition & 1 deletion website/content/ChapterTwo/Depth_First_Search.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ weight: 9
|0756|Pyramid Transition Matrix|[Go]({{< relref "/ChapterFour/0700~0799/0756.Pyramid-Transition-Matrix.md" >}})|Medium||||55.9%|
|0778|Swim in Rising Water|[Go]({{< relref "/ChapterFour/0700~0799/0778.Swim-in-Rising-Water.md" >}})|Hard||||55.3%|
|0783|Minimum Distance Between BST Nodes|[Go]({{< relref "/ChapterFour/0700~0799/0783.Minimum-Distance-Between-BST-Nodes.md" >}})|Easy||||54.6%|
|0785|Is Graph Bipartite?|[Go]({{< relref "/ChapterFour/0700~0799/0785.Is-Graph-Bipartite.md" >}})|Medium||||49.1%|
|0785|Is Graph Bipartite?|[Go]({{< relref "/ChapterFour/0700~0799/0785.Is-Graph-Bipartite.md" >}})|Medium||||49.0%|
|0802|Find Eventual Safe States|[Go]({{< relref "/ChapterFour/0800~0899/0802.Find-Eventual-Safe-States.md" >}})|Medium||||50.5%|
|0834|Sum of Distances in Tree|[Go]({{< relref "/ChapterFour/0800~0899/0834.Sum-of-Distances-in-Tree.md" >}})|Hard||||47.3%|
|0839|Similar String Groups|[Go]({{< relref "/ChapterFour/0800~0899/0839.Similar-String-Groups.md" >}})|Hard||||42.6%|
Expand Down
2 changes: 1 addition & 1 deletion website/content/ChapterTwo/Segment_Tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ weight: 18
| No. | Title | Solution | Difficulty | TimeComplexity | SpaceComplexity |Favorite| Acceptance |
|:--------:|:------- | :--------: | :----------: | :----: | :-----: | :-----: |:-----: |
|0218|The Skyline Problem|[Go]({{< relref "/ChapterFour/0200~0299/0218.The-Skyline-Problem.md" >}})|Hard| O(n log n)| O(n)|❤️|37.1%|
|0307|Range Sum Query - Mutable|[Go]({{< relref "/ChapterFour/0300~0399/0307.Range-Sum-Query-Mutable.md" >}})|Medium| O(1)| O(n)||37.6%|
|0307|Range Sum Query - Mutable|[Go]({{< relref "/ChapterFour/0300~0399/0307.Range-Sum-Query-Mutable.md" >}})|Medium| O(1)| O(n)||37.7%|
|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%|
|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%|
|0493|Reverse Pairs|[Go]({{< relref "/ChapterFour/0400~0499/0493.Reverse-Pairs.md" >}})|Hard| O(n log n)| O(n)||27.7%|
Expand Down

3 comments on commit b012a1f

@haowan1015
Copy link

@haowan1015 haowan1015 commented on b012a1f Apr 2, 2024 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiaokuer
Copy link

@xiaokuer xiaokuer commented on b012a1f Apr 2, 2024 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@honguangli
Copy link

@honguangli honguangli commented on b012a1f Apr 2, 2024 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.