File tree Expand file tree Collapse file tree 5 files changed +59
-0
lines changed Expand file tree Collapse file tree 5 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -399,6 +399,8 @@ image_support = false,
399399
400400 - ` update ` updates cache
401401
402+ - ` top_interview ` opens top interview 150 questions
403+
402404#### Some commands can take optional arguments. To stack argument values separate them by a ` , `
403405
404406- ` Leet list `
Original file line number Diff line number Diff line change @@ -131,4 +131,23 @@ function Problems.translated_titles(cb)
131131 end
132132end
133133
134+ function Problems .top_interview_150 (cb )
135+ local query = queries .top_interview_150
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+
134153return Problems
Original file line number Diff line number Diff line change @@ -179,4 +179,16 @@ queries.session_progress = [[
179179 }
180180 ]]
181181
182+ queries .top_interview_150 = [[
183+ query studyPlanDetail($slug: String!) {
184+ studyPlanV2Detail(planSlug: $slug) {
185+ planSubGroups {
186+ questions {
187+ title_slug: titleSlug
188+ }
189+ }
190+ }
191+ }
192+ ]]
193+
182194return queries
Original file line number Diff line number Diff line change @@ -83,6 +83,14 @@ function Problemlist.update()
8383 end , true )
8484end
8585
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+
8694--- @return lc.cache.Question
8795function Problemlist .get_by_title_slug (title_slug )
8896 local problems = Problemlist .get ()
Original file line number Diff line number Diff line change @@ -141,6 +141,21 @@ function cmd.qot()
141141 end )
142142end
143143
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+
144159function cmd .random_question (opts )
145160 require (" leetcode.utils" ).auth_guard ()
146161
@@ -651,6 +666,9 @@ cmd.commands = {
651666 cmd .random_question ,
652667 _args = arguments .random ,
653668 },
669+ top_iterview = {
670+ cmd .top_interview_150 ,
671+ },
654672 desc = {
655673 cmd .desc_toggle ,
656674
You can’t perform that action at this time.
0 commit comments