From 8692927a1274f6c936713cd94375210441468522 Mon Sep 17 00:00:00 2001 From: WHMHammer Date: Sat, 30 May 2026 20:53:05 -0500 Subject: [PATCH] feat: add hints --- lib/commands/show.js | 8 ++++++++ lib/plugins/leetcode.js | 2 ++ package.json | 2 +- templates/detailed.tpl | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/commands/show.js b/lib/commands/show.js index 93f643e2..6239b09d 100644 --- a/lib/commands/show.js +++ b/lib/commands/show.js @@ -175,6 +175,14 @@ function showProblem(problem, argv) { log.info(); log.info(problem.desc); + + for (let i = 0; i < problem.hints.length; i++) { + log.info(); + log.info('
'); + log.info(`\tHint ${i + 1}:`); + log.info(`\t

${problem.hints[i]}

`); + log.info('
'); + } } cmd.handler = function(argv) { diff --git a/lib/plugins/leetcode.js b/lib/plugins/leetcode.js index 93d66053..71b2fff3 100644 --- a/lib/plugins/leetcode.js +++ b/lib/plugins/leetcode.js @@ -140,6 +140,7 @@ plugin.getProblem = function(problem, needTranslation, cb) { ' enableRunCode', ' metaData', ' translatedContent', + ' hints', ' }', '}' ].join('\n'), @@ -167,6 +168,7 @@ plugin.getProblem = function(problem, needTranslation, cb) { problem.testcase = q.sampleTestCase; problem.testable = q.enableRunCode; problem.templateMeta = JSON.parse(q.metaData); + problem.hints = q.hints; // @si-yao: seems below property is never used. // problem.discuss = q.discussCategoryId; diff --git a/package.json b/package.json index 93c650b6..8eb2caea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vsc-leetcode-cli", - "version": "2.8.0", + "version": "2.8.4", "description": "A cli tool to enjoy leetcode!", "engines": { "node": ">=4" diff --git a/templates/detailed.tpl b/templates/detailed.tpl index 7329a7d7..daa46b78 100644 --- a/templates/detailed.tpl +++ b/templates/detailed.tpl @@ -14,6 +14,10 @@ ${comment.line} Total Submissions: ${totalSubmit} ${comment.line} Testcase Example: ${testcase} ${comment.line} {{ desc.forEach(function(x) { }}${comment.line} ${x} +{{ }) }}{{ hints.forEach(function(hint, index) { }}${comment.line} +${comment.line} Hint ${index + 1}: +${comment.line} +${comment.line} ${hint} {{ }) }}${comment.end} ${comment.singleLine} @lc code=start