Skip to content

Commit c28e1c0

Browse files
committed
Add solution 1600, change dir 0167、0303、0304、0307、0653、1017
1 parent fe99f9d commit c28e1c0

39 files changed

+758
-416
lines changed

README.md

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

ctl/models/mdrow.go

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,37 @@ type Mdrow struct {
1818

1919
// GenerateMdRows define
2020
func GenerateMdRows(solutionIds []int, mdrows []Mdrow) {
21-
//fmt.Printf("solutionIds = %v\n\n", solutionIds)
21+
mdMap := map[int]Mdrow{}
22+
for _, row := range mdrows {
23+
mdMap[int(row.FrontendQuestionID)] = row
24+
}
2225
for i := 0; i < len(solutionIds); i++ {
23-
//fmt.Printf("solutionIds[i] = %v id = %v - %v\n", solutionIds[i], mdrows[solutionIds[i]].FrontendQuestionID, mdrows[solutionIds[i]].QuestionTitle)
24-
id := mdrows[solutionIds[i]-1].FrontendQuestionID
25-
if solutionIds[i] == int(id) {
26-
//fmt.Printf("id = %v i = %v solutionIds = %v\n", id, i, solutionIds[i])
27-
mdrows[id-1].SolutionPath = fmt.Sprintf("[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/%v)", fmt.Sprintf("%04d.%v", id, strings.Replace(strings.TrimSpace(mdrows[id-1].QuestionTitle), " ", "-", -1)))
26+
if row, ok := mdMap[solutionIds[i]]; ok {
27+
mdMap[solutionIds[i]] = Mdrow{
28+
FrontendQuestionID: row.FrontendQuestionID,
29+
QuestionTitle: row.QuestionTitle,
30+
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+
Acceptance: row.Acceptance,
33+
Difficulty: row.Difficulty,
34+
Frequency: row.Frequency,
35+
}
2836
} else {
29-
fmt.Printf("序号出错了 len(solutionIds) = %v len(mdrows) = %v len(solutionIds) = %v solutionIds[i] = %v id = %v - %v\n", len(solutionIds), len(mdrows), len(solutionIds), solutionIds[i], id, mdrows[solutionIds[i]-1].QuestionTitle)
37+
fmt.Printf("序号不存在 len(solutionIds) = %v len(mdrows) = %v len(solutionIds) = %v solutionIds[i] = %v QuestionTitle = %v\n", len(solutionIds), len(mdrows), len(solutionIds), solutionIds[i], mdrows[solutionIds[i]-1].QuestionTitle)
38+
}
39+
}
40+
for i := range mdrows {
41+
mdrows[i] = Mdrow{
42+
FrontendQuestionID: mdrows[i].FrontendQuestionID,
43+
QuestionTitle: mdrows[i].QuestionTitle,
44+
QuestionTitleSlug: mdrows[i].QuestionTitleSlug,
45+
SolutionPath: mdMap[int(mdrows[i].FrontendQuestionID)].SolutionPath,
46+
Acceptance: mdrows[i].Acceptance,
47+
Difficulty: mdrows[i].Difficulty,
48+
Frequency: mdrows[i].Frequency,
3049
}
3150
}
51+
// fmt.Printf("mdrows = %v\n\n", mdrows)
3252
}
3353

3454
// | 0001 | Two Sum | [Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0001.Two-Sum)| 45.6% | Easy | |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)