my leetcode
  • JavaScript 98.3%
  • Python 1.2%
  • PowerShell 0.5%
Find a file
2026-11-01 13:09:12 +03:00
.vscode Updates to behavior and some solutions 2026-10-29 20:33:00 +03:00
data Updates to behavior and some solutions 2026-10-29 20:33:00 +03:00
lib Colored cli and extra solutions 2026-10-31 18:13:43 +03:00
own-solutions Clear on start and solutions 2026-11-01 13:09:12 +03:00
scripts Clear on start and solutions 2026-11-01 13:09:12 +03:00
solutions Updates to behavior and some solutions 2026-10-29 20:33:00 +03:00
test Colored cli and extra solutions 2026-10-31 18:13:43 +03:00
types Add offline JavaScript problem practice workspace 2026-10-29 16:54:18 +03:00
vscode-extension Open completed questions as unsaved retakes 2026-10-31 15:00:27 +03:00
.gitignore Keep generated practice folders and answers out of Git 2026-10-29 17:32:54 +03:00
CATALOG.md Finish requested batch at 80 authored JavaScript solutions 2026-10-29 17:28:30 +03:00
hi.md Add offline JavaScript problem practice workspace 2026-10-29 16:54:18 +03:00
jsconfig.json Add offline JavaScript problem practice workspace 2026-10-29 16:54:18 +03:00
package.json Preserve personal solutions and progress when clearing practice folders 2026-10-29 18:38:42 +03:00
README.md Clear on start and solutions 2026-11-01 13:09:12 +03:00
SOLUTION_PROGRESS.md Updates to behavior and some solutions 2026-10-29 20:33:00 +03:00

Local LeetCode practice

Solve problems in VS Code with JavaScript autocomplete, local tests, debugging, and reference solutions included when you load a question. No login, subscription, npm packages, or running server is required. Node.js 22 or newer runs the practice tools; Node.js is already installed here.

Start here

In VS Code's terminal, run:

npm start

Use Up/Down and Enter to choose an action:

  • Load question — enter a question number such as 1768. Its Markdown preview and REFERENCE.js are tabs on the left; your solution.js opens on the right.
  • Check question — run the current question's local tests.
  • Find a question — search by number or title, then choose a result with arrow keys.
  • Study plans — follow LeetCode 75, Top Interview 150, or Top 100 Liked in their official topic groups and question order.
  • View progress — see your latest local test results.
  • Clear problems (save answers first) — save your answers and progress in own-solutions/, then empty problems/.
  • Exit — close the menu.

Starting the interactive menu clears the terminal. The menu remembers your current question between sessions. After an action, press Enter to return to it. You can leave it running while editing your answer. Esc goes back or cancels an entry; Ctrl+C exits. A small VS Code layout helper is installed from this project's local source on first use. If VS Code is not installed, the file paths are printed.

Menus keep the selected item near the center of the visible list, clamping at either end and adjusting when the terminal is resized. Cyan highlights the selection and titles; magenta identifies topics. Green marks completed/passing results and Easy questions, yellow marks warnings and Medium questions, and red marks failures and Hard questions. Navigation hints and not-started states are muted. Colors turn off automatically for redirected output, NO_COLOR, and TERM=dumb; labels and selection markers remain visible.

Completed questions open the real solution.js with its contents replaced by the blank starter as an unsaved edit. You can immediately write a fresh answer, press Ctrl+Z to undo the replacement and see your previous answer, or Ctrl+S to save your new version. The saved answer and check results stay intact until the file is saved. This applies when loading by number, search, study plans, or an interactive npm start -- <number>. Unfinished questions open your existing work immediately. Noninteractive commands continue to restore saved files normally.

Loading a question from any menu saves file edits, closes all current editor tabs, and opens only that question's statement/reference on the left and answer on the right. Unsaved retakes and untitled/custom editors use VS Code's normal save/discard/cancel handling; a failed save or canceled close stops the switch. Your practice folders and archived answers remain on disk.

npm run menu opens the same menu. Bare npm run is npm's built-in script listing, so use npm start to launch the interactive tool. Saved answers and progress live in own-solutions/ and can be committed to Git. The menu selection stays local.

Keep LeetCode's normal function signature in solution.js; no export or input-reading boilerplate is needed. Starters are blank until you implement them. Checks cover your local cases, not LeetCode's hidden tests.

Study plans

Choose Study plans in npm start, then select LeetCode 75, Top Interview 150, or Top 100 Liked. Each plan shows its completed total and one scrolling question list, with topic headings, group totals, difficulty, and personal progress. The topic for the selected question stays visible while scrolling. Up/Down, Page Up/Page Down, Home, and End move between questions and skip headings. Every visit starts at the first question in official order, even if it is complete. Esc returns to the plan chooser, then to the main menu.

Press Enter on a question to load it into the usual editor layout. After the normal pause, the main menu's Check question uses that question. Answers restore from own-solutions/ as usual. Browsing plans alone generates no practice folders or progress files.

Completion comes directly from your existing answers and latest local check results: Complete means every local case passed, at least one case ran, and the answer still matches that check. Active practice folders also require unchanged tests and runner configuration. After clearing, the archived answer is compared with its saved code fingerprint, ignoring Windows/Unix line-ending differences. Shared questions count in both plans. No separate checklist or plan progress file is stored.

Rows distinguish Not started, In progress (an unchecked answer), Failed check, Changed since check, and Check needed (no verifiable result). Save editor changes before checking. Older results without a code fingerprint need another check unless their active practice files still match the original combined fingerprint. Complete reflects local tests, not LeetCode acceptance or account progress.

Setup needed marks questions whose tests or runner adapter require configuration. They load normally; use the existing custom-test/runner flow before checking them. Clearing removes that custom setup, so a previously checked archived answer may still require setup when revisited.

All three plans work offline from data/study-plans.json, an official API snapshot dated 29 October 2026 of LeetCode 75, Top Interview 150, and Top 100 Liked. The snapshot preserves official order, groups, and difficulty, even where our problem catalog differs (such as problem 222). Dataset re-imports preserve it; browsing does not fetch or synchronize with LeetCode.

Individual commands (optional)

The existing commands also work if you prefer them:

npm run list -- two sum
npm run list -- --difficulty Easy --topic Array --with-tests
npm run list -- --difficulty Medium --topic "Binary Search" --js
npm run list -- --all
npm start -- 20
npm start -- reverse-linked-list
npm start -- random --difficulty Easy --with-tests

Or browse CATALOG.md. Load question (or npm start -- <number>) creates a folder under problems/ containing:

File Purpose
README.md Statement, constraints, examples, and illustrations
solution.js Your code, initially the JavaScript starter
tests.json Editable example tests and your own cases
problem.json Runner entry point and type information
REFERENCE.js Included reference solution, when available

Loading the same problem again reuses its folder, files, and two editor groups. Your existing answer, tests, and reference notes are preserved. Older generated local practice instructions in the question's README are refreshed when you load it. Statements for every imported problem are stored locally; practice folders are created as you choose problems. The problems/ folder is ignored by Git. Loading, checking, and clearing questions copy your saved-on-disk answers into Git-visible files such as own-solutions/1431-kids-with-the-greatest-number-of-candies.js. Untouched starters are omitted; unfinished answers are saved too. When a practice folder is regenerated, its saved answer is restored automatically. An existing practice answer takes precedence over its archived copy.

Clear practice folders

Save your editor changes, then choose Clear problems (save answers first) from the menu, or run:

npm run clear

The command saves and verifies all answers before removing any practice folders. Your code and latest local check results remain in own-solutions/, ready to commit. View progress still includes questions whose practice folders have been cleared. Loading a question again regenerates its statement, reference, tests, and runner configuration, and restores your answer.

Clearing removes custom tests, runner edits, README notes, and reference notes along with the generated files. Only your solution.js and progress are archived. Unsaved editor edits cannot be copied; save them before clearing. Unknown files or folders inside problems/ stop the command so you can move them elsewhere first.

Check and debug

npm run check -- 20
npm run progress

Loading creates REFERENCE.js automatically when a JavaScript reference is available. Your solution.js remains your own answer. References are kept out of normal workspace search. Questions without a reference still load normally.

With solution.js active, Terminal → Run Task → Practice: check current problem runs its cases. Set a breakpoint and press F5, selecting Debug current problem, to step through your code. Normal checks have a two-second execution limit per phase of each case; the debug configuration disables this limit while you inspect your program.

Progress records the most recent local check and tells you when your code or cases have changed since that check. It is stored in own-solutions/progress.json; existing .local/progress.json results are migrated when you load, check, or clear questions. For archived answers, progress shows the last saved code's result; regenerated or changed tests require a fresh check. It does not label a problem solved automatically.

Add your own tests

tests.json is a JSON array. args contains function arguments in signature order, so an array argument sits inside the outer argument array:

[
  {
    "name": "Duplicates",
    "args": [[3, 3], 6],
    "expected": [0, 1],
    "compare": "unordered"
  }
]

Comparison defaults to exact equality. Use unordered to ignore the outer array's order, unordered-nested when ordering is irrelevant at every array level, or approx for numbers/numeric arrays (tolerance defaults to 0.00001). With compare: "one-of", expected is an array of valid answers. A few common problems have appropriate ordering rules preselected; adjust other cases to match their statements.

For an in-place task such as Move Zeroes, set returnArg to the zero-based index of the argument to inspect:

[
  {
    "args": [[0, 1, 0, 3, 12]],
    "returnArg": 0,
    "expected": [1, 3, 12, 0, 0]
  }
]

For Remove Duplicates from Sorted Array, the return value specifies how much of the mutated argument matters:

[
  {
    "args": [[1, 1, 2]],
    "returnArg": 0,
    "prefixFromReturn": true,
    "expected": { "length": 2, "values": [1, 2] }
  }
]

Ordinary linked lists use value arrays such as [1,2,3]. Binary trees use LeetCode's level-order arrays such as [1,null,2,3]. ListNode and TreeNode constructors are supplied at runtime and declared for editor autocomplete.

Class/design problems use operations and arguments, with the constructor first:

[
  {
    "operations": ["MinStack", "push", "top"],
    "arguments": [[], [4], []],
    "expected": [null, null, 4]
  }
]

Coverage and limits

This snapshot was imported on 29 October 2026 from all four splits of whiskwhite/leetcode-complete. It contains 3,997 statements, including entries marked Premium, 3,676 JavaScript starters, and automatic example cases for 3,564 problems. This is a community snapshot, with no guarantee that it includes every current LeetCode problem.

Local checks cover only tests.json, not LeetCode's hidden tests, performance judging, or every valid-output rule. Automatic example extraction skips formats it cannot parse confidently. Review cases against the statement and add edge cases. Special judges, async/function-returning exercises, graphs, cyclic lists, node-reference inputs, and other unusual signatures may need custom adapters or your own runner. LeetCode-specific helper libraries such as its priority queues are not supplied. The runner executes synchronous JavaScript; SQL and other language-specific statements remain available to read.

The downloaded collection has 2,719 matching JavaScript references from JoshCrozier/leetcode-javascript. The repository has 2,786 reference files in total; some do not correspond to problems in this snapshot. Its MIT license is preserved in data/SOLUTIONS-LICENSE.txt. This batch adds 80 manually authored JavaScript references in solutions/javascript, bringing the matching total to 2,799 and leaving 877 JavaScript algorithm gaps. Work stops at 80 additions as requested; see SOLUTION_PROGRESS.md for coverage. Database problems are outside that task. Dataset-generated solutions are not used as JavaScript references. The dataset publisher lists its own license as unknown; source links and download checksums are recorded in data/provenance.json.

Imported references have not all been audited against algorithm restrictions or complexity requirements. Matching example outputs does not verify those requirements. Known corrections are maintained separately in solutions/corrections, currently including a multiplication-only reference for problem 238. Corrections survive re-imports, and loading a question replaces its exact obsolete generated reference while preserving your own answer and reference notes.

1,738 illustrations are cached locally. Seven image URLs in the snapshot are unavailable or malformed; data/image-report.json lists them. Text, code, cached images, tests, and references work offline. Links to the original pages are optional.

Maintenance

The data/ folder is hidden in VS Code's Explorer/search to keep problems easy to browse. It remains on disk; change files.exclude in .vscode/settings.json if you want to inspect it.

To download a fresh snapshot and regenerate the catalog (requires internet):

.\scripts\download.ps1 -Images

Python 3 is used only for the optional image download; everyday practice uses Node.js. Refreshing the dataset preserves existing practice folders. To re-import already downloaded source files, run npm run import. To check the practice tools, run npm test.