@@ -51,7 +51,9 @@ type questionType struct {
51
51
Dislikes int `json:"dislikes"`
52
52
IsLiked int `json:"isLiked"`
53
53
SimilarQuestions string `json:"similarQuestions"`
54
+ TopicTags []tagType `json:"topicTags"`
54
55
CodeSnippets []codeSnippetsType `json:"codeSnippets"`
56
+ Hints []string `json:"hints"`
55
57
}
56
58
57
59
type codeSnippetsType struct {
@@ -82,11 +84,26 @@ func (question questionType) getDescContent() []byte {
82
84
buf .WriteString ("<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->" )
83
85
buf .WriteString (authInfo )
84
86
buf .WriteString (fmt .Sprintf ("\n ## %s. %s%s\n \n " , question .QuestionFrontendId , question .Title , question .Difficulty ))
85
- //remove style
87
+ // remove style
86
88
reg , err := regexp .Compile (`<style[\S\s]+?</style>` )
87
89
checkErr (err )
88
90
buf .WriteString (reg .ReplaceAllString (question .Content , "" ))
91
+ buf .Write (question .getTopicTags ())
89
92
buf .Write (question .getSimilarQuestion ())
93
+ buf .Write (question .getHints ())
94
+ return buf .Bytes ()
95
+ }
96
+
97
+ func (question questionType ) getTopicTags () []byte {
98
+ tags := question .TopicTags
99
+ var buf bytes.Buffer
100
+ if len (tags ) > 0 {
101
+ buf .WriteString ("\n \n ### Related Topics\n " )
102
+ }
103
+ format := "[[%s](https://github.com/openset/leetcode/tree/master/tag/%s/README.md)] "
104
+ for _ , tag := range tags {
105
+ buf .WriteString (fmt .Sprintf (format , tag .Name , tag .Slug ))
106
+ }
90
107
return buf .Bytes ()
91
108
}
92
109
@@ -109,6 +126,18 @@ func (question questionType) getSimilarQuestion() []byte {
109
126
return buf .Bytes ()
110
127
}
111
128
129
+ func (question questionType ) getHints () []byte {
130
+ hints := question .Hints
131
+ var buf bytes.Buffer
132
+ if len (hints ) > 0 {
133
+ buf .WriteString ("\n ### Hints\n " )
134
+ }
135
+ for _ , hint := range hints {
136
+ buf .WriteString (fmt .Sprintf (" 1. %s\n " , hint ))
137
+ }
138
+ return buf .Bytes ()
139
+ }
140
+
112
141
func (question questionType ) getFilePath (filename string ) string {
113
142
return path .Join ("problems" , question .TitleSlug , filename )
114
143
}
0 commit comments