Skip to content

Commit 9d4849b

Browse files
author
openset
committed
Add: translatedTitle
1 parent 0cf5c9f commit 9d4849b

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

Diff for: internal/leetcode/question_data.go

+23-12
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (question *questionType) getDescContent() []byte {
119119
question.Title,
120120
question.Difficulty.Str(),
121121
question.LeetCodeURL(),
122-
question.TranslatedTitle,
122+
question.translatedTitle(),
123123
))
124124
cts := filterContents(question.Content)
125125
// remove style
@@ -134,21 +134,32 @@ func (question *questionType) getDescContent() []byte {
134134
return buf.Bytes()
135135
}
136136

137+
func (question *questionType) questionID() int {
138+
id, _ := strconv.Atoi(question.QuestionID)
139+
return id
140+
}
141+
142+
func (question *questionType) translatedTitle() string {
143+
if question.TranslatedTitle == "" {
144+
question.TranslatedTitle = translationSet[question.questionID()]
145+
}
146+
return question.TranslatedTitle
147+
}
148+
137149
func (question *questionType) getNavigation() string {
138150
nav, pre, next := "\n%s\n%s\n%s\n", "< Previous", "Next >"
139151
problems := ProblemsAll().StatStatusPairs
140-
if id, err := strconv.Atoi(question.QuestionID); err == nil {
141-
format := `[%s](https://github.com/openset/leetcode/tree/master/problems/%s "%s")`
142-
for i, problem := range problems {
143-
if problem.Stat.QuestionID == id {
144-
if i < len(problems)-1 {
145-
pre = fmt.Sprintf(format, pre, problems[i+1].Stat.QuestionTitleSlug, problems[i+1].Stat.QuestionTitle)
146-
}
147-
if i > 0 {
148-
next = fmt.Sprintf(format, next, problems[i-1].Stat.QuestionTitleSlug, problems[i-1].Stat.QuestionTitle)
149-
}
150-
break
152+
id := question.questionID()
153+
format := `[%s](https://github.com/openset/leetcode/tree/master/problems/%s "%s")`
154+
for i, problem := range problems {
155+
if problem.Stat.QuestionID == id {
156+
if i < len(problems)-1 {
157+
pre = fmt.Sprintf(format, pre, problems[i+1].Stat.QuestionTitleSlug, problems[i+1].Stat.QuestionTitle)
158+
}
159+
if i > 0 {
160+
next = fmt.Sprintf(format, next, problems[i-1].Stat.QuestionTitleSlug, problems[i-1].Stat.QuestionTitle)
151161
}
162+
break
152163
}
153164
}
154165
return fmt.Sprintf(nav, pre, strings.Repeat(" ", 16), next)

Diff for: problems/closest-binary-search-tree-value/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515

1616
### Related Topics
17-
[[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)]
1817
[[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)]
18+
[[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)]
1919

2020
### Similar Questions
2121
1. [Count Complete Tree Nodes](https://github.com/openset/leetcode/tree/master/problems/count-complete-tree-nodes) (Medium)

Diff for: problems/design-skiplist/README.md

-5
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,3 @@ skiplist.search(1); // return false, 1 has already been erased.</pre>
6161

6262
### Related Topics
6363
[[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)]
64-
65-
### Similar Questions
66-
1. [Design HashSet](https://github.com/openset/leetcode/tree/master/problems/design-hashset) (Easy)
67-
1. [Design HashMap](https://github.com/openset/leetcode/tree/master/problems/design-hashmap) (Easy)
68-
1. [Design Linked List](https://github.com/openset/leetcode/tree/master/problems/design-linked-list) (Easy)

Diff for: problems/highest-grade-for-each-student/README.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/reported-posts "Reported Posts")
1111

12-
## [1112. Highest Grade For Each Student (Medium)](https://leetcode.com/problems/highest-grade-for-each-student "")
12+
## [1112. Highest Grade For Each Student (Medium)](https://leetcode.com/problems/highest-grade-for-each-student "每位学生的最高成绩")
1313

1414

15-
16-
### Similar Questions
17-
1. [Department Highest Salary](https://github.com/openset/leetcode/tree/master/problems/department-highest-salary) (Medium)

0 commit comments

Comments
 (0)