File tree 5 files changed +59
-0
lines changed
5 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -399,6 +399,8 @@ image_support = false,
399
399
400
400
- ` update ` updates cache
401
401
402
+ - ` top_interview ` opens top interview 150 questions
403
+
402
404
#### Some commands can take optional arguments. To stack argument values separate them by a ` , `
403
405
404
406
- ` Leet list `
Original file line number Diff line number Diff line change @@ -131,4 +131,23 @@ function Problems.translated_titles(cb)
131
131
end
132
132
end
133
133
134
+ function Problems .top_interview_150 (cb )
135
+ local query = queries .study_plan_detail
136
+
137
+ utils .query (query , { slug = " top-interview-150" }, {
138
+ callback = function (res , err )
139
+ if err then
140
+ return cb (nil , err )
141
+ end
142
+ local title_slugs = {}
143
+ for _ , v in ipairs (res .data [" studyPlanV2Detail" ][" planSubGroups" ]) do
144
+ for _ , q in ipairs (v [" questions" ]) do
145
+ table.insert (title_slugs , q .title_slug )
146
+ end
147
+ end
148
+ return cb (title_slugs )
149
+ end
150
+ })
151
+ end
152
+
134
153
return Problems
Original file line number Diff line number Diff line change @@ -179,4 +179,16 @@ queries.session_progress = [[
179
179
}
180
180
]]
181
181
182
+ queries .study_plan_detail = [[
183
+ query studyPlanDetail($slug: String!) {
184
+ studyPlanV2Detail(planSlug: $slug) {
185
+ planSubGroups {
186
+ questions {
187
+ title_slug: titleSlug
188
+ }
189
+ }
190
+ }
191
+ }
192
+ ]]
193
+
182
194
return queries
Original file line number Diff line number Diff line change @@ -83,6 +83,14 @@ function Problemlist.update()
83
83
end , true )
84
84
end
85
85
86
+ --- @return lc.cache.Question
87
+ function Problemlist .get_by_title_slugs (title_slugs )
88
+ local problems = Problemlist .get ()
89
+ return vim .tbl_filter (function (e )
90
+ return vim .tbl_contains (title_slugs , e .title_slug )
91
+ end , problems )
92
+ end
93
+
86
94
--- @return lc.cache.Question
87
95
function Problemlist .get_by_title_slug (title_slug )
88
96
local problems = Problemlist .get ()
Original file line number Diff line number Diff line change @@ -141,6 +141,21 @@ function cmd.qot()
141
141
end )
142
142
end
143
143
144
+ function cmd .top_interview_150 ()
145
+ require (" leetcode.utils" ).auth_guard ()
146
+
147
+ local problems = require (" leetcode.api.problems" )
148
+
149
+ problems .top_interview_150 (function (slugs , err )
150
+ if err then
151
+ return log .err (err )
152
+ end
153
+ local p = require (" leetcode.cache.problemlist" ).get_by_title_slugs (slugs )
154
+ local picker = require (" leetcode.picker" )
155
+ picker .question (p )
156
+ end )
157
+ end
158
+
144
159
function cmd .random_question (opts )
145
160
require (" leetcode.utils" ).auth_guard ()
146
161
@@ -651,6 +666,9 @@ cmd.commands = {
651
666
cmd .random_question ,
652
667
_args = arguments .random ,
653
668
},
669
+ top_iterview = {
670
+ cmd .top_interview_150 ,
671
+ },
654
672
desc = {
655
673
cmd .desc_toggle ,
656
674
You can’t perform that action at this time.
0 commit comments