Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>LeetCode Problem FetcherNew to Visual Studio Code? Get it now.
LeetCode Problem Fetcher

LeetCode Problem Fetcher

nas03

|
107 installs
| (1) | Free
Fetch LeetCode problem descriptions and starter code into your editor, in 19 of the languages LeetCode offers: the language of your file by default, Python3 otherwise, or the one the setting leetcode.language names
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

LeetCode Logo

🧩 LeetCode Problem Fetcher

Instantly fetch LeetCode problems into your editor with smart autocomplete

VS Code Marketplace Downloads License

Features • Usage • Demo • Development


A powerful Cursor/VS Code extension that automatically fetches LeetCode problem descriptions and starter code, then inserts them directly into your editor as clean, readable comments — a docstring in Python. It writes in 19 of the languages LeetCode offers: the language of your file by default, Python3 otherwise, or the one the setting leetcode.language names.

✨ Features

Feature Description
🔍 Smart Autocomplete Type the start of a problem number and see its matches, lowest number first (e.g., "8" → 8, 80, 81, 82, ...), from LeetCode's whole problem list, the newest problems included. At most 10 problems are listed, so type more digits to narrow it down
📝 Clean Docstrings Problem descriptions formatted as Python triple-quote docstrings, or as the comments of another language when the file's language or the setting leetcode.language chooses one (see Settings)
🧭 Topics and Link The docstring's header names the problem's topics and its URL on LeetCode; a setting leaves the header out (see Settings)
💻 Starter Code Automatically includes LeetCode's code template in the language of the file — Python3 otherwise —, or in the one the setting leetcode.language names
🌳 Auto-Uncomment Classes The TreeNode, ListNode, etc. definitions LeetCode ships as comments are uncommented
⭐ Favourites Click the star of a problem in the list of LeetCode: Fetch Problem or LeetCode: New Problem File to keep it as a favourite: the favourites are listed before you type, and first among the problems a search finds (see Favourites)
🎯 Prefix Search Search by problem number, by a title's text, or "number. title"; every search runs over the problem list in memory. Start with e:, m: or h: to search the Easy, Medium or Hard problems alone
🚀 Fast & Cached Uses LeetCode's GraphQL API. Every search runs over LeetCode's problem list, which the extension keeps for 24 hours: the first search each day downloads the list (about 42 requests) and every later one asks LeetCode for nothing. A problem you fetched is kept for 5 minutes, so fetching it again needs no second request
✂️ No Examples Clutter Automatically removes verbose example sections; a setting keeps them (see Settings)
📅 Daily Challenge LeetCode: Fetch Daily Problem inserts the problem LeetCode features today, without a search
🔄 List Refreshed on Demand LeetCode: Refresh Problem List downloads LeetCode's problem list again, so that a problem published since the list was kept is found without waiting a day
🔗 A Problem's Link, In Two Commands LeetCode: Open Problem in Browser opens the page of the problem in the active file on LeetCode, and LeetCode: Copy Problem Link puts the page's address on the clipboard. Neither asks LeetCode
📄 One File per Problem LeetCode: New Problem File puts a problem you search for into a file of its own (1-two-sum.py, 1-two-sum.java) and opens it. A file that exists already is opened, never overwritten
🏃 A File That Runs A setting makes the Python3 starter code run as it is: a typing import above it, pass in every empty body under a one-line def or class, and a main block with a call of the method for each example (see Settings)
📌 Top of the File or at the Cursor A problem goes above the first line of the file by default. A setting, leetcode.insertPosition, has LeetCode: Fetch Problem and LeetCode: Fetch Daily Problem put it where the cursor is instead (see Settings)
🔁 Fetched Again, Replaced Run LeetCode: Fetch Problem or LeetCode: Fetch Daily Problem again for a problem whose description is at the top of the file, and the description is replaced instead of put in twice. The code under it stays, and the starter code is not written again (see Quick Start)
🌐 Other Languages A setting, leetcode.language, has LeetCode: Fetch Problem, LeetCode: Fetch Daily Problem and LeetCode: New Problem File write the description in the comments of another language (Java, C++, Go, Kotlin, Swift, …) above the starter code LeetCode gives for it. By default the language of the file decides (see Settings)
🖱️ One Click in the Status Bar A LeetCode item at the left of the status bar runs LeetCode: Fetch Problem. It is there once VS Code has started: the extension activates at start-up for it. Right-click the status bar to hide it
💡 Hints, One at a Time LeetCode: Show Hints asks LeetCode for the hints of the problem in the active file — or of the one fetched last — and lists them one at a time, the newest on top: Enter reveals the next, and nothing reveals it before that
▶️ Examples Run Locally LeetCode: Run Examples runs the solution in the active Python file on the problem's examples and reports PASS or FAIL for each, with what came back and what was expected, in an Output channel
🐞 Examples in the Debugger LeetCode: Debug Examples runs the same examples under the Python extension's debugger, so a breakpoint in your solution stops them

🚀 Usage

Keyboard Shortcut

Command Mac Windows/Linux
LeetCode: Fetch Problem (in a focused editor) Option+Cmd+J Cmd+L Ctrl+Alt+J Ctrl+L
LeetCode: Fetch Daily Problem Option+Cmd+J Cmd+D Ctrl+Alt+J Ctrl+D
LeetCode: New Problem File Option+Cmd+J Cmd+N Ctrl+Alt+J Ctrl+N
LeetCode: Refresh Problem List Option+Cmd+J Cmd+R Ctrl+Alt+J Ctrl+R
LeetCode: Open Problem in Browser Option+Cmd+J Cmd+O Ctrl+Alt+J Ctrl+O
LeetCode: Copy Problem Link Option+Cmd+J Cmd+C Ctrl+Alt+J Ctrl+C
LeetCode: Show Hints Option+Cmd+J Cmd+I Ctrl+Alt+J Ctrl+I
LeetCode: Run Examples (in a focused editor) Option+Cmd+J Cmd+E Ctrl+Alt+J Ctrl+E
LeetCode: Debug Examples (in a focused editor) Option+Cmd+J Cmd+G Ctrl+Alt+J Ctrl+G

Each is a chord: press the first pair, release it, then press the second while the status bar reads "Waiting for second key of chord". All of them start with the same first pair. LeetCode: Fetch Problem inserts into the editor that has the focus, and LeetCode: Run Examples and LeetCode: Debug Examples run the file in it, so their chords work there alone; the others work wherever the focus is but in a terminal, which keeps the first pair for its shell. To change one, open Preferences: Open Keyboard Shortcuts and search for leetcode.. Measured on macOS with VS Code 1.148.0: the first pair starts each chord, and the chords of LeetCode: Fetch Problem, LeetCode: Fetch Daily Problem, LeetCode: Refresh Problem List, LeetCode: Open Problem in Browser, LeetCode: Copy Problem Link, LeetCode: New Problem File and LeetCode: Show Hints run their commands; the second keys of LeetCode: Run Examples and LeetCode: Debug Examples were not pressed, and the Windows/Linux chords were not measured.

Changed from Cmd+D Cmd+L / Ctrl+D Ctrl+L, the default up to version 1.0.4. While this extension was installed, Cmd+D / Ctrl+D no longer added the next occurrence to the selection, in any editor: VS Code gives an extension's chord priority over its own command for the same first key. (Confirmed on macOS with VS Code 1.148.0. Ctrl+D is the same command in VS Code's default Windows/Linux keybindings; there this was not measured.) The new Mac first key, Option+Cmd+J, is one that VS Code does not use in an editor — not in a plain text file, with the suggest widget or the find widget open, in snippet mode, or in a Python file — so nothing of VS Code's is switched off there. Outside an editor, with the file tree of the Explorer or the Output panel focused, VS Code does not use it either, and in a terminal no chord of this extension starts there (VS Code 1.74.0 and 1.148.0). A notebook was not measured. Ctrl+Alt+J is its Windows/Linux counterpart; that key has not been measured yet.

To get the old shortcut back — together with that conflict — open Preferences: Open Keyboard Shortcuts (JSON) and add the line for your platform (only the Mac line was measured):

// Mac
{ "key": "cmd+d cmd+l", "command": "leetcode.fetchProblem", "when": "editorTextFocus" }
// Windows/Linux
{ "key": "ctrl+d ctrl+l", "command": "leetcode.fetchProblem", "when": "editorTextFocus" }

Quick Start

  1. Open any file in Cursor/VS Code (preferably a .py file)
  2. Click LeetCode in the status bar (bottom left), press the shortcut or open Command Palette (Cmd+Shift+P on Mac, Ctrl+Shift+P on Windows/Linux)
  3. Run: LeetCode: Fetch Problem
  4. Search for a problem using any of these formats:
    • By number: 841
    • By number prefix: 8 (8, 80, 81, 82, ..., the lowest numbers first)
    • By title: Two Sum
    • Combined: 1. Two Sum
    • Within one difficulty: start with e:, m: or h: — h: alone, h: 4, e: sum
  5. Select from the list
  6. Done! The problem is inserted at the top of the file that was active when you ran the command — or, with leetcode.insertPosition set to cursor, where the cursor is (see Settings). If you switched to another file while LeetCode answered, the file you ran the command in takes the problem all the same. Shown in another group meanwhile, it takes it there, and the focus stays where it is. Shown as either side of a diff editor meanwhile — in another group or over the file's own —, it takes it there too: the problem goes into that file, and the diff's other side is left alone. Shown nowhere, it is shown again in front of its own group, over the file you switched to when that is the one in front there — and it takes the focus when that file had it, so what you type next goes into the problem's file; with the focus in another group, it does not. A focus that moved on from that file to the terminal or a QuickPick meanwhile is not told apart: the file shown again takes it there too. A file you closed meanwhile is not opened again, and that is reported. Something typed into the file as the problem goes in is no obstacle by itself: the problem is put in once more, by the file as it is by then — above what you typed, or by the cursor as it is by then

Run it again for the same problem and the description is replaced, not put in twice: the code under it stays as it is, and the starter code is not written again. The description is known by the header it starts with (leetcode.showHeader), which names the problem by its number. In a language whose description is line comments (//, --, #), the description ends at its last line where the file holds it as the extension writes it — now, or with leetcode.keepExamples the other way, spaces at the ends of its lines trimmed on save or not: a comment of yours right under it — the blank line between them deleted or kept — is left alone. A description that differs otherwise from the one fetched — edited since, or changed on LeetCode — is read to its last line that is a comment, so a comment of yours right under it goes with it. With the header off, or for another problem, nothing is replaced: the problem goes in as described above, beside what the file has. With leetcode.insertPosition set to cursor, the description is replaced when the cursor is in it or above it; below it, the problem goes in where the cursor is, as a second copy.

Search Examples

Input Results
841 Problem 0841
0841 Problem 0841 too: leading zeros, as the list writes a number, are dropped. Zeros alone match nothing
84 The problems whose number starts with 84: 0084, 0840, 0841, 0842, ...
Two Sum The problems whose title contains "Two Sum", whatever the case — 0001 and 0167 among them — lowest number first
sum The problems whose title contains "sum", wherever it stands in the title: 0001 Two Sum, 0015 3Sum, 0016 3Sum Closest, 0018 4Sum, ...
841. Keys The problems whose title contains "Keys" and whose number starts with 841 — 0841, Keys and Rooms; when there are none, the problems whose title contains "Keys", whatever their number. VS Code hides such a line unless it matches what was typed: "4. Keys" and "7. Keys" show nothing. To find those problems, type the title alone (Keys)

A title is searched for as the text you typed it, so its words are found in the title's order and next to each other.

Start what you type with e:, m: or h: and the search runs over the Easy, Medium or Hard problems alone. The prefix goes before any of the forms above: alone (m:), before a number (h: 4), a title (e: sum) or "number. title" (m: 1. sum). The letter may be typed in either case.

Input Results
e: sum The Easy problems whose title contains "sum": 0001 Two Sum first
h: 8 The Hard problems whose number starts with 8: 0084 first
m: Every Medium problem, lowest number first: 0002 and 0008 among them

The list shows at most 10 problems, lowest number first. Of those, VS Code shows only the lines that match what you typed: as you type on, a row whose line no longer does is hidden at once, by VS Code's own filter, which waits for no search. Every row of a search that starts with e:, m: or h: is an exception, and stays whatever you type: no line of a problem contains the prefix. The row of a failed search is one too (see "Troubleshooting").

The list searches again once you stop typing. Until the new rows are in, the old ones stay and the list shows that it is busy. So after m: two was found, typing on to m: two zzz still shows the problems found for m: two, and Enter fetches the one that has the focus. Type the prefix away — two — and those rows stay too, but no longer whatever you type: VS Code's filter narrows them at once to the ones whose line matches, as for any search without the prefix — when none does, the list is empty until the new rows are in, and Enter there closes it. Only when you delete all you typed does the list change at once: it shows your favourites again.

Favourites

Every problem in the list of LeetCode: Fetch Problem and LeetCode: New Problem File has a star at the right of its row. Click it to keep the problem as a favourite — the star fills — and click it again to drop it. The favourites are kept from one VS Code session to the next, for every workspace, and with Settings Sync on they follow you to your other machines.

  • Before you type, and once you clear what you typed, the list shows your favourites, in the order you starred them, without asking LeetCode. Each is shown with the title and the difficulty that the problem list the extension keeps holds for it, so a problem LeetCode has renamed or given another difficulty is listed as it is now. Until the extension keeps that list — it is downloaded by a search, and kept for a day —, a favourite is as it was when you starred it. Pick one as any other problem. A favourite you unstar there stays listed, with an empty star, until you type.
  • In a search, the favourites among the problems found come first, each part lowest number first. The search lists at most 10 problems, and the favourites that match come before that limit: a favourite is listed even when more than 10 other problems with lower numbers match. The row you starred stays where it is until the next search.

Daily Challenge

No search is needed for the problem LeetCode features today: run LeetCode: Fetch Daily Problem from the Command Palette. It inserts today's daily coding challenge where LeetCode: Fetch Problem puts a problem you searched for: at the top of the file that was active when you ran the command, or where the cursor is when leetcode.insertPosition says so (see "Settings"). It is written in the language the setting leetcode.language and that file choose (see "Settings"), so a Python docstring with Python3's starter code by default. It reports a failure with the same messages (see "Troubleshooting"), and a setting that names no language too, before LeetCode is asked for the challenge. Its shortcut is Option+Cmd+J Cmd+D (Mac) / Ctrl+Alt+J Ctrl+D (Windows/Linux).

New Problem File

To solve a problem in a file of its own, run LeetCode: New Problem File from the Command Palette and pick a problem from the list LeetCode: Fetch Problem shows, with the same search. The file is named after the problem and the language it is written in (1-two-sum.py; 1-two-sum.java when the language is Java) and holds the same description and starter code as a picked problem; VS Code then opens it. The language is the one leetcode.language names (see Settings); at the default, auto, it is Python3, because the command reads no file: it needs none to be open, and nothing is inserted into an editor. A file that exists already is opened and left as it is, so a solution in it is never overwritten; an empty one is filled with the problem — unless it is open with unsaved edits, when it is opened as it is —, and a folder in the file's place is reported, not opened. Languages that share an extension get a file each: one made in Pandas or in a SQL dialect other than MySQL says which language it is written in before the extension (1-two-sum.pythondata.py, 175-combine-two-tables.postgresql.sql), and a Python3 or MySQL file keeps the extension alone (1-two-sum.py, 175-combine-two-tables.sql). The file goes into the folder of leetcode.workspaceFolder (see Settings). With no folder (none open in VS Code and the setting not an absolute path) the command says so and does nothing; so does a setting that names no language, before the list opens. Its shortcut is Option+Cmd+J Cmd+N / Ctrl+Alt+J Ctrl+N.

Refresh Problem List

Every search runs over LeetCode's problem list, which the extension keeps for 24 hours. A problem LeetCode published since the list was downloaded is not found until the list is a day old; run LeetCode: Refresh Problem List from the Command Palette to download the list again then and there (about 42 requests) and to be told how many problems it holds. When LeetCode does not deliver it, the command reports the cause (see "Troubleshooting") and the list the extension had is left as it was. Every window is meant to take the refreshed list: when another VS Code window searches next, it takes the list this command stored, which is newer than the one it kept in memory. Whether one window sees what another stored has not been measured, the extension's tests opening one window, so that is a check to run by hand; until it is made, run the command in that window as well. No file needs to be open. Its shortcut is Option+Cmd+J Cmd+R / Ctrl+Alt+J Ctrl+R. Cancel on its progress notification stops the download: no message, and the list the extension had stays. The download of the list — by this command, or by a search once a day — is given 2 minutes in all, its pages and their retries together; past them it ends with The problem list could not be downloaded in time and keeps nothing. The 2 minutes count from the start of the download: a command that joins one already on its way waits for what is left of them. With leetcode.requestTimeoutSeconds above 120, a page that is not answered ends with that message, not with LeetCode did not answer in time.

Problem Link

LeetCode: Open Problem in Browser opens a problem's page on LeetCode in your browser, and LeetCode: Copy Problem Link puts the page's address on the clipboard and says which address it copied. Neither asks LeetCode. The address is the URL: line of the docstring at the top of the active file — the docstring LeetCode: Fetch Problem, LeetCode: Fetch Daily Problem and LeetCode: New Problem File write in Python (see the demo below); a docstring that stands under imports is not read. When the active file gives none — leetcode.showHeader is off, the file was written in another language's comments (a Java file, say: only a Python docstring is read so far), another file is active, no file is open —, the address is that of the problem the extension fetched last since VS Code loaded it: the file's own problem only when it was the last one fetched, otherwise another one's. With neither, the command says so (see "Troubleshooting"). Their shortcuts: Option+Cmd+J Cmd+O / Ctrl+Alt+J Ctrl+O opens, Option+Cmd+J Cmd+C / Ctrl+Alt+J Ctrl+C copies.

Show Hints

Run LeetCode: Show Hints from the Command Palette when you want a nudge. It asks LeetCode for the hints of the problem at hand and opens a list, Hints for two-sum, titled with the problem's name in its address on LeetCode. The first hint is in the list from the start; Enter reveals the next and puts it on top, so that the next is not read before you ask for it. Each hint is wrapped in rows of at most 50 characters, and its first row is tagged Hint 1, Hint 2, and so on; typing in the list hides no row, but while the text stands VS Code may list the rows in an order of its own. Enter clears the text as it reveals the next hint, leaving it on top with its rows together. Enter on the last hint closes the list, and so do Escape and the focus leaving it for the editor. A hint is a spoiler, so nothing is asked for until the command runs, and the hints are not kept: each run asks LeetCode once.

The problem is the one named in the URL: line of the docstring at the top of the active file, when the line holds an address of a problem's page like https://leetcode.com/problems/two-sum/; a docstring that stands under imports is not read. When the active file names none — leetcode.showHeader is off, another file is active, no file is open —, the problem is the one the extension fetched last since VS Code loaded it. With neither, the command says so and asks LeetCode for nothing. A problem LeetCode lists no hints for is reported by a message, and a failed request as Error: with the cause (see "Troubleshooting"). A hint LeetCode sends blank adds no row: it counts as revealed all the same. Its shortcut is Option+Cmd+J Cmd+I / Ctrl+Alt+J Ctrl+I.

Run Examples

Open the Python file of your solution and run LeetCode: Run Examples (Option+Cmd+J Cmd+E / Ctrl+Alt+J Ctrl+E in the editor). It asks LeetCode for the problem's examples, calls the method of a new Solution on each with its arguments, and writes to the Output channel LeetCode: Run Examples one line per example — PASS example 1, or FAIL example 2: got [2,1], expected [1,2] —, the count, and below them what your code printed. A method that raises fails its example with the last line of the traceback, and the next example runs. A file with unsaved changes is saved first (so format-on-save runs).

  • Python alone. The active file must be a Python file saved on this machine; any other file is refused by a message.
  • What is compared. What the method returns is compared with the Output: of each example in the description: a list item by item and in order — an answer LeetCode accepts in any order is a FAIL here when its order differs —, a float within 1e-5, true with a boolean alone. A linked list or a tree is built from LeetCode's list (ListNode, TreeNode), and one that is returned is turned back into it.
  • Design problems (a class the examples make and call, such as LRUCache, MinStack) are run too: each example makes a new instance by its first call and calls the rest of its methods on it in order, each with its arguments. A failure names the call — FAIL example 1, call 4 (get): got 2, expected 1 — and the calls after it are not made. What a method LeetCode says returns nothing is not looked at, as on LeetCode.
  • In place. A method that returns nothing and changes an argument in place (void, as Rotate Array and Merge Sorted Array do) is run too: the method is called, and the argument LeetCode names for the problem is compared with the Output: of the example after the call — what the method returned is not looked at. A linked list or a tree changed in place is turned back into LeetCode's list, as one that is returned is — read back from the nodes it was built from, not from what the method returned. That is as LeetCode's answer is captured for Reorder List and Flatten Binary Tree to Linked List.
  • Not run: the examples of a problem whose types the extension cannot build, and of a problem whose description does not state one output per example — of a design problem, one output per call: a message says which. Among the types is a method that returns nothing where LeetCode names no argument it changes: its message names the type LeetCode gives the return, void.
  • The problem is the one named in the URL: line of the docstring at the top of the file, and no other: a file without it is refused, even when a problem was fetched before.
  • The names LeetCode gives a solution are given here too, without an import: List, Optional and the rest of typing; deque, defaultdict, Counter, OrderedDict and the rest of collections; the functions of heapq, bisect, math (inf, gcd, sqrt…), itertools and functools (lru_cache, reduce…), but never in the place of a builtin (pow stays Python's); the modules collections, heapq, bisect, math, itertools, functools, operator, string, re, random and copy; ListNode and TreeNode. Your file's own imports and definitions take their place. bisect is the module: write bisect.bisect_left(a, x) or a bare bisect_left(a, x); a bare bisect(a, x) is not supported, as it calls the module. SortedList, SortedDict and SortedSet (the package sortedcontainers) are given when the interpreter has the package and not when it does not: the line of the NameError for one of them then ends with pip install sortedcontainers.
  • The interpreter is the one the setting python.defaultInterpreterPath names (of the Python extension; ${workspaceFolder} and a leading ~ are read), else python3. The run is stopped after 10 seconds. A script of the extension is written to a folder of its own in the system's temporary folder and removed after: nothing is written into your project — the runner has Python write no bytecode, so no __pycache__ folder is left beside your solution.

Debug Examples

Open the Python file of your solution, set a breakpoint in it, and run LeetCode: Debug Examples (Option+Cmd+J Cmd+G / Ctrl+Alt+J Ctrl+G in the editor). It runs the examples as LeetCode: Run Examples does — the same script, the same comparison, the same names given to your solution — under the debugger of the Python extension, which stops at your breakpoints. Nothing is written to .vscode/launch.json: the debug configuration is the command's own.

  • Needs the Python extension (ms-python.python, with its Python Debugger). Without it a message offers to install it.
  • The interpreter is the one the Python extension has selected (Python: Select Interpreter), not python.defaultInterpreterPath as for Run Examples, and there is no time limit.
  • The problem is the one named in the URL: line of the docstring at the top of the file, and no other: a file without it is refused.
  • The report (PASS example 1, FAIL example 2: …) goes to the Debug Console, among what your code prints.
  • An exception your solution raises does not stop the debugger at Uncaught Exceptions: the runner catches it and reports the example as a FAIL. Tick Raised Exceptions in the Breakpoints view to stop where it is raised.
  • input() waits forever: the Debug Console gives a running program no input.
  • The script is written to a folder of its own in the system's temporary folder, kept so that Restart runs it again, and removed at the next run of the command or when VS Code closes.

Settings

Setting Default Effect
leetcode.keepExamples false By default the Examples section of a problem is left out of the docstring. Turn this on to keep it, as plain text, for every command
leetcode.showHeader true The docstring starts with the problem's header: its title, its number and difficulty, its topics and its URL on LeetCode. Turn this off to insert the description and the starter code alone
leetcode.makeRunnable false The Python3 starter code runs as it is: from typing import * above it, pass in every body LeetCode left empty under a one-line def or class, and an if __name__ == "__main__": block with a call of the method for each example of the problem, for every command that fetches a problem. By default the starter code is inserted as LeetCode wrote it
leetcode.cacheTtlMinutes 5 For how many minutes a problem fetched once is served again from memory, by every command that fetches a problem, before LeetCode is asked for it again. 0 asks LeetCode every time. A value the setting does not take — a negative number, a string — counts as 5
leetcode.requestTimeoutSeconds 15 After how many seconds a request LeetCode has not answered is given up, by every command that asks LeetCode — and reported as LeetCode did not answer in time (see "Troubleshooting"). From 1 to 600. A value the setting does not take — 0, a negative number, more than 600, a string — counts as 15
leetcode.workspaceFolder (empty) The folder LeetCode: New Problem File puts a problem's file in. An absolute path, or a path inside the workspace's first folder. Empty: a folder named leetcode in the workspace's first folder
leetcode.language auto The language LeetCode: Fetch Problem, LeetCode: Fetch Daily Problem and LeetCode: New Problem File write a problem in: one of the values the setting offers, as LeetCode names them (java, golang, cpp, python3, …), or auto for the language of the file — Python3 for the file LeetCode: New Problem File makes
leetcode.insertPosition top Where LeetCode: Fetch Problem and LeetCode: Fetch Daily Problem put a problem in the file that was active: top, above its first line; cursor, where the cursor is — above the line the cursor is on when the cursor is at its start, otherwise below that line. No line of the file is cut in two, and nothing of it is removed. The description of the same problem is replaced where the problem goes, not put in twice (see Quick Start)

leetcode.keepExamples, leetcode.showHeader and leetcode.makeRunnable are read each time a problem is fetched, so a change to one of them applies to the next problem you fetch. leetcode.cacheTtlMinutes is read each time a problem could be served from memory, so a change applies at once, to the problems fetched before it too. The list of all problems the search runs over is not affected: it is kept for a day. leetcode.requestTimeoutSeconds is read at each request LeetCode is sent, so a change applies to the next one. Each request has its own deadline: the list of all problems, fetched in pages of 100, gives each page that many seconds, and the whole list 2 minutes at most.

A request that fails for a cause that may pass — Could not reach LeetCode, LeetCode did not answer in time, LeetCode is rate-limiting requests or LeetCode had a server error — is sent again, twice at most: after half a second to a second, then after one to two seconds. After an HTTP 429 the extension waits what LeetCode's Retry-After asks instead, up to 30 seconds; when it asks for longer, the message comes at once. An HTTP 429 without a Retry-After waits five to ten seconds before each of the two retries, so at worst 20 seconds of waiting before its message. The pages of the list of all problems share those two retries, so a failing LeetCode is asked at most two times more than there are pages. A retry has its own deadline: with the default leetcode.requestTimeoutSeconds, a request that never gets an answer is reported after 46 to 48 seconds, and one that LeetCode keeps rate-limiting with a Retry-After of 30 seconds after about a minute and three answers. The messages of "Troubleshooting" on a failed request come after the last try.

leetcode.workspaceFolder takes an absolute path, used as it is, or a relative one, which lies inside the workspace's first folder. ~ is not expanded: ~/leetcode is a folder named ~ inside that folder. .. is taken as written, so a relative path can leave the first folder. On Windows, give an absolute path with its drive letter (C:\problems): /problems has none, and C:problems is joined into the first workspace folder, to a path that is no folder.

leetcode.language is read when LeetCode: Fetch Problem, LeetCode: Fetch Daily Problem or LeetCode: New Problem File runs, so a change applies to the next problem you fetch with any of them. Set it to a value the setting offers, spelled as LeetCode spells it: java, cpp, golang for Go, kotlin, pythondata for Pandas. The description then goes into the file as comments of that language, above the starter code LeetCode gives for it. At auto the language is the file's: a .java file gets Java and a .go file Go; a file in a language the extension does not write in, plain text for one, gets Python3. LeetCode: New Problem File makes a file of its own and reads none, so at auto its file is Python3's. Pandas and three of the four SQL dialects have no file language of their own in VS Code (sql is MySQL's), so only the setting asks for them. A value the setting does not offer is reported when the command runs, and nothing is fetched (see "Troubleshooting"): before the list opens, for the two commands that show one. LeetCode: New Problem File reads the setting again when you pick, so a value set while its list is open is what the pick meets.

leetcode.insertPosition is read when LeetCode: Fetch Problem or LeetCode: Fetch Daily Problem is about to insert a problem, so a change applies to the next problem you fetch with either. At cursor the problem goes in as whole lines: above the cursor's line when the cursor is at that line's start, and below that line otherwise — on a new line when the cursor is on the last line of a file that does not end with one. Nothing selected is removed, and of several cursors the first decides. The place is the cursor's when LeetCode has answered, wherever it was moved to meanwhile. A value the setting does not offer — a typo, another case — is read as top, and nothing is reported. LeetCode: New Problem File writes a file of its own and does not read the setting.

📸 Demo

After fetching problem 1. Two Sum, the top of your file starts like this. The block is the text the extension builds for the Two Sum answer src/test/unit/fixtures.ts keeps (written to mirror LeetCode's markup, not captured from it); a unit test compares it with the code, so it shows the extension's real formatting:

r"""
Two Sum
LeetCode 1 - Difficulty: Easy
Topics: Array, Hash Table
URL: https://leetcode.com/problems/two-sum/

Given an array of integers 'nums' and an integer 'target', return indices of the two numbers such that they add up to 'target'.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

You can return the answer in any order.

Constraints:

• '2 <= nums.length <= 10^4'

• '-10^9 <= nums[i] <= 10^9'

• Only one valid answer exists.

Follow-up: Can you come up with an algorithm that is less than 'O(n^2)' time complexity?
"""

class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:

In another language — a .java file at the default of leetcode.language, or the setting set to java — the description goes into that language's comments, above the starter code LeetCode gives for it. The same problem in Java (a unit test compares this block with the code too):

/*
Two Sum
LeetCode 1 - Difficulty: Easy
Topics: Array, Hash Table
URL: https://leetcode.com/problems/two-sum/

Given an array of integers 'nums' and an integer 'target', return indices of the two numbers such that they add up to 'target'.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

You can return the answer in any order.

Constraints:

• '2 <= nums.length <= 10^4'

• '-10^9 <= nums[i] <= 10^9'

• Only one valid answer exists.

Follow-up: Can you come up with an algorithm that is less than 'O(n^2)' time complexity?
*/

class Solution {
    public int[] twoSum(int[] nums, int target) {

    }
}

For tree and linked-list problems, LeetCode's starter code also carries a class definition, as comments; the extension uncomments it:

# Definition for a binary tree node.
class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

With leetcode.makeRunnable on, the starter code runs as it is: from typing import * stands above it, pass fills every body LeetCode left empty under a def or class on one line, and an if __name__ == "__main__": block calls the method once for each example of the problem, with the input as LeetCode states it (null, true and false become None, True and False). The Two Sum file of the demo then goes on below its docstring like this — the docstring is unchanged; a unit test compares this part with the code:

"""

from typing import *

class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        pass


if __name__ == "__main__":
    print(Solution().twoSum(nums=[2,7,11,15], target=9))
    print(Solution().twoSum(nums=[3,2,4], target=6))

Not built yet: a tree or a linked list is passed as LeetCode's list of values, so nothing makes nodes of it; the expected output is not written next to a call; and a problem whose Input: stands alone on its line (a design problem, such as MinStack) gives no call, so its file has no main block. LeetCode's starters were not captured for the tests, so one of a shape they do not know — a def wrapped over two lines — may still need a pass by hand.

The docstring is a raw string (r"""): a backslash in a problem description is inserted as LeetCode wrote it, so it cannot turn into an escape sequence, join two lines or make Python reject the file. Three double quotes in a row, which would end the docstring, are written as ""\".

Entities in LeetCode's HTML are decoded (&lt;, &hellip;, &#x27;, …), and a code block in a description, such as the table schema of a database problem, keeps its alignment, indented by four spaces. An ordered list keeps its numbers and a nested list its indentation, each row of a table stands on its own line with its cells separated by |, and an image leaves its address in the text as [image: …].

✨ Key Features Shown:

  • Header: the title, LeetCode's number and difficulty, the topics and the URL on LeetCode. Topics: is left out for a problem LeetCode files under no topic
  • Clean docstring: The description as a docstring, without the Examples section — in Java, a block comment
  • Plain text, not Markdown: list items as • bullets, inline code in quotes ('nums'), superscripts as ^
  • Starter code: LeetCode's Python3 template follows the docstring — its Java template the Java comment; for trees and linked lists the class definition of the Python3 template is uncommented

🎯 Why This Extension?

Before (Manual Process)

  1. Open LeetCode website
  2. Find the problem
  3. Copy the description
  4. Format it as a docstring
  5. Copy the starter code
  6. Paste everything into your editor
  7. Time: 2-3 minutes per problem

After (With This Extension)

  1. Press Option+Cmd+J Cmd+L (Mac) or Ctrl+Alt+J Ctrl+L (Windows/Linux) → Search → Select
  2. Time: 5 seconds

Perfect for:

  • 📚 Daily LeetCode practice
  • 🎓 Interview preparation
  • 📖 Building a solutions repository
  • ⚡ Speed coding sessions

⚙️ How It Works

┌─────────────────┐     ┌───────────────────────┐     ┌──────────────────┐     ┌─────────────────────┐
│   User Input    │ ──▶ │   Problem List        │ ──▶ │   LeetCode API   │ ──▶ │   Format & Insert   │
│   "8"           │     │   (kept for 24 hours) │     │   (GraphQL)      │     │   (the active file) │
└─────────────────┘     └───────────────────────┘     └──────────────────┘     └─────────────────────┘
         │                          │                          │                          │
         ▼                          ▼                          ▼                          ▼
      What you type       Search in the problem list:   Fetch the problem       Docstring or comments
                          8, 80, 81...                  picked: description     with the starter code,
                          No search asks LeetCode;      and starter code        in the language
                          the list is downloaded                                leetcode.language chooses
                          once a day                                            (the file's language
                                                                                by default,
                                                                                Python3 otherwise)
  1. Parse Input: Detects if input is a number prefix, title, or combined format — and whether a difficulty prefix (e:, m:, h:) comes before it
  2. Search: Finds the matching problems in LeetCode's problem list, which the extension keeps for 24 hours and downloads once a day (about 42 requests). No search asks LeetCode by itself
  3. Fetch Details: Uses GraphQL API to get problem content and code snippets
  4. Clean & Format: Removes the examples (unless leetcode.keepExamples is on), converts HTML to clean text, and makes the starter code runnable when leetcode.makeRunnable is on
  5. Insert: Places the docstring and the starter code at the top of the file that was active when the command ran, before its first line — or where the cursor is, when leetcode.insertPosition is cursor. Where the file already holds the description of that problem, the description is replaced and the starter code is not written again

🛠️ Development

Project Structure

leetcode-extension/
├── src/                    # TypeScript: the extension and its tests
│   ├── extension.ts            # activate(): makes the one crawler and registers the commands
│   ├── pickProblem.ts          # The list of the two commands that pick a problem; "LeetCode: Fetch Problem" then calls fetchAndInsert
│   ├── pickedProblem.ts        # What a pick in the list hands over: the number, the title and LeetCode's slug
│   ├── favourites.ts           # The problems starred in the list, as they are kept in globalState: read back, starred or unstarred, listed first, shown as LeetCode lists them
│   ├── languageSetting.ts      # The setting leetcode.language, as a command reads it: the language a problem is written in
│   ├── insertPosition.ts       # Where a fetched problem goes in a document: above the first line, or by the cursor, as the setting leetcode.insertPosition says; in the place of the description of the same problem, where there is one
│   ├── fetchAndInsert.ts       # Fetches a problem, formats it and inserts it: at the top of the file, or where the cursor is; where the file holds the description of that problem, replaces it
│   ├── daily.ts                # The command "LeetCode: Fetch Daily Problem": today's challenge, without a list
│   ├── newFile.ts              # The command "LeetCode: New Problem File": the shared list, then a file of the problem's own, in the language the setting leetcode.language names
│   ├── refreshList.ts          # The command "LeetCode: Refresh Problem List": the problem list fetched again, whatever the kept one says
│   ├── showHints.ts            # The command "LeetCode: Show Hints": a problem's hints asked for, then revealed one at a time in a list
│   ├── runExamples.ts          # The command "LeetCode: Run Examples": the runner's script written to a temporary folder, Python started on it, the report in an Output channel
│   ├── debugExamples.ts        # What Debug Examples will do: the runner of Run Examples started under the Python extension's debugger, with a configuration of its own
│   ├── statusBar.ts            # The status-bar item "LeetCode", which runs "LeetCode: Fetch Problem"
│   ├── problemLink.ts          # The commands "LeetCode: Open Problem in Browser" and "LeetCode: Copy Problem Link": a problem's link read from the active file, else from the last fetch
│   ├── problemFile.ts          # The name of a problem's own file — its number, its slug and the extension of its language — and its folder; opens the file or creates it
│   ├── problemFileDisk.ts      # The file system behind problemFile.ts
│   ├── search/query.ts         # parseSearchQuery: the typed text as a difficulty, a number and a title
│   ├── search/local.ts         # searchProblemList: the search over a list of problems in memory (every search uses it)
│   ├── leetcodeCrawler.ts      # The requests to LeetCode, and a cache of their answers
│   ├── text/html.ts            # LeetCode's HTML as plain text
│   ├── text/languages.ts       # The languages a problem can be written in, each with the comments its description is written in, and how the setting and the editor choose one
│   ├── text/examples.ts        # Removes the Examples section, before and after the conversion to text
│   ├── text/python.ts          # The docstring; docstringUrl, which reads the link of a problem back from it; problemComments, which finds the description a fetch of the same problem replaces; the starter code with its class definitions uncommented
│   ├── text/runnable.ts        # The code of a file made runnable: the typing import, `pass` in empty bodies, the main block and the calls
│   ├── text/hints.ts           # The rows a hint becomes for a list, at most 50 characters each, and the slug in the address of a problem's page
│   ├── text/literal.ts         # The value of an example as LeetCode writes it, read into a tree and written back as Python writes it
│   ├── text/exampleCases.ts    # Each example as the runner of Run Examples takes it: the arguments by the types of metaData, the expected output
│   ├── text/runnerScript.ts    # The Python script of Run Examples: it imports your file, calls Solution's method on each example — or the methods a design problem's example names — and reports PASS or FAIL
│   ├── text/debugConfiguration.ts # The debug configuration of Debug Examples, and the debugger type it names: debugpy, or python of an older Python extension
│   ├── leetcodeApi.ts          # The HTTP request, the response types and LeetCodeError
│   ├── test/unit/              # Unit tests (Vitest); responses/ holds captured LeetCode answers
│   ├── test/suite/             # Extension tests (Mocha), run inside VS Code
│   ├── test/runTest.ts         # Downloads VS Code and runs the extension tests in it
│   ├── test/vscodeVersion.ts   # Which VS Code a test run asks for, and where its profile lives
│   └── test/vscodeDownload.ts  # The download of VS Code behind npm run test:ext, under a deadline
├── out/                    # Compiled JavaScript
├── package.json            # Extension manifest
├── tsconfig.json           # TypeScript configuration
├── CHANGELOG.md            # Version history
├── BACKLOG.md              # What to do next
├── LICENSE                 # MIT License
└── README.md               # You are here!

Building

# Install dependencies (exactly the versions in package-lock.json)
npm ci

# Compile TypeScript into out/, then bundle the extension (axios included) into out/extension.js with esbuild
npm run compile

# Watch mode (auto-compile on save, and bundle out/extension.js again after every compilation)
npm run watch

# Package as VSIX: the bundle, the manifest, README, CHANGELOG, LICENSE and the icon, no node_modules
npm run package

Testing Locally

  1. Open the project in Cursor/VS Code
  2. Press F5 to launch Extension Development Host
  3. In the new window, run LeetCode: Fetch Problem

Automated Tests and CI

npm test                 # Unit tests (Vitest), no network
npm run test:ext         # Extension tests inside a downloaded VS Code (~370 MB on first run)
npm run test:ext:floor   # The same tests on the oldest VS Code version the extension supports (a second download)
npm run check            # Compile + lint + unit tests

A download of VS Code that has not finished after ten minutes fails the run — npm run test:ext, the floor run and the keybinding probe alike — instead of waiting for ever, and the archive it staged is removed. npm run check must pass before a change is committed. One of its unit tests, src/test/unit/readme.test.ts, reads this README: it checks it against package.json, its error messages against the code (each way: every piece of a message the Troubleshooting table names occurs in the code, and every error of LeetCode's the code can raise has its row), the project structure above against the files under src/, the demo against the text the extension builds, its search examples against what the search finds, the diagram of "How It Works" against sentences of its text that the spec repeats — of a search, of the problem picked and of the starter code —, and the numbers it states for the search — the pause after a keystroke, how many problems are listed, how long a problem and the list are kept, how long the download of the list is given — and the seconds it states for a request's deadline, for what LeetCode's rate limiting adds to a request, for "Run Examples" and for that download — against what the code does, each way: a number changed in this README alone, or in the code alone, fails it; and so does a number stated anywhere in this README with one of their units (ms, s, problems, hours, minutes; seconds too, and each in any form: singular, abbreviated, hyphenated, behind an entity) that nothing reads — the spec's message says which line, and what to do.

Every push and pull request also runs .github/workflows/ci.yml: on Node 22 and 24 (Ubuntu) it runs npm ci, npm run check, the extension tests and the keybinding probe (node scripts/test/keybinding.test.js: what that VS Code does with the default shortcuts); a job of its own, on Node 22, runs the extension tests again on the oldest VS Code version the extension supports (npm run test:ext:floor); and a job of its own, on Node 22 and Windows, runs the keybinding probe again, which no other job does on Windows. The three runs on Ubuntu are on a virtual display; the one on Windows is not. .github/dependabot.yml configures Dependabot to open pull requests once a week, for newer actions in that workflow and for newer dev dependencies; a maintainer reviews and merges them.

📋 Requirements

  • Editor: Cursor IDE or VS Code 1.74+
  • Network: Internet connection to fetch problems

❓ Troubleshooting

A problem cannot be fetched, inserted or put into its own file, the problem list cannot be refreshed, a problem's link is not found, opened or copied, a problem's hints are not shown, its examples are not run or debugged, or a search fails with "Search error"

The error message names the cause. Of the last five rows, all but the one on Error: and one of LeetCode's messages belong to LeetCode: New Problem File alone. A failed search reports it too, in the list itself: one row labelled Search error with the cause under it. It stays there while you type, until an empty input or the result of a newer search replaces it, and nothing pops up. The row is not a problem: pressing Enter on it closes the list and fetches nothing. Before, a failed search left the list empty, as if nothing matched:

The message contains Cause What to do
LeetCode has no problem "…" LeetCode no longer knows that problem Search again by title. From LeetCode: Show Hints, see its own row below
"…" (…) is a LeetCode Premium problem LeetCode gives this description to subscribers only Nothing to fix; pick another problem
"…" (…) has no … starter code on LeetCode, then Set "leetcode.language" to one of those this extension supports or LeetCode offers it in no language this extension supports LeetCode has no code for it in the language the problem was to be written in. That is the one leetcode.language names. At auto it is the language of the active file for LeetCode: Fetch Problem and LeetCode: Fetch Daily Problem — Python3 for a file in none of them —, and Python3 for LeetCode: New Problem File, which reads no file (database and Pandas problems have no Python3 code). The message names the language, those LeetCode offers, and those of them this extension supports With any of the three commands, set leetcode.language to one of the slugs the message names after this extension supports. When it names none, there is none to ask for: pick another problem
is not a language this extension supports A language the extension does not know was asked for. No command asks for one: it is refused before LeetCode is asked Nothing was fetched. Report the message
"leetcode.language" is set to The setting names no language the extension supports: a typo, another case than LeetCode's (Python3), or a language the extension leaves out (php, python, which is LeetCode's Python 2). LeetCode: Fetch Problem reports it before its list opens, so nothing is searched or fetched, and so does LeetCode: New Problem File; LeetCode: Fetch Daily Problem reports it before LeetCode is asked for today's challenge Set it to auto or to a value the setting offers, spelled as it lists it
Could not reach LeetCode The request failed before LeetCode answered: no connection, a name lookup failure, a dropped connection Check your internet connection, then try again
LeetCode is rate-limiting requests Too many requests in a short time Wait a minute, then try again
LeetCode did not answer in time LeetCode took too long to answer: longer than leetcode.requestTimeoutSeconds (15 seconds by default), or the connection timed out first Try again; on a slow connection, raise leetcode.requestTimeoutSeconds
The problem list could not be downloaded in time The list of all problems, about 42 pages that a search fetches once a day and LeetCode: Refresh Problem List fetches again, took longer than 2 minutes in all, its retries included. No list was kept: the list kept before stays Try again
The download of the problem list was cancelled Never shown: Cancel on the progress notification of LeetCode: Refresh Problem List stops the download without a message. Nothing of it is kept, and the list kept before stays Nothing to fix
LeetCode refused the request … Try again later., LeetCode did not return data, LeetCode did not return the problem list, LeetCode did not return today's daily challenge or LeetCode had a server error LeetCode blocked the request, is unavailable, or answered without the problem list (none, or none counted) Try again in a few minutes
LeetCode refused the request … the extension may need an update LeetCode's website answered with an error page, or nothing, instead of its API Try again later; if it keeps happening, update the extension
LeetCode answered the request LeetCode's answer could not be read Try again
LeetCode rejected the query or has an unexpected shape LeetCode's API changed in a way this version does not know Update the extension
LeetCode says it lists LeetCode counts more problems than this version of the extension reads (10000). No list was kept Update the extension
No active editor found No file was active when you ran LeetCode: Fetch Problem or LeetCode: Fetch Daily Problem. The first then opens no list, and neither asks LeetCode. LeetCode: New Problem File needs no file Open a file and run the command again
Could not insert the problem The file that was active when you ran the command did not take it: it was closed while LeetCode answered, or the file changed at that moment and once more as the problem was put in again — something typed into the file as the problem goes in is no obstacle by itself: the problem is put in once more, by the file as it is by then — save where it would have replaced its description and would no longer by the file as it is then (a line typed above the description, say): nothing is written then, rather than a second description and starter. A file that is still open takes the problem all the same, even when another file was shown in front of it meanwhile: shown nowhere, it is shown again in front of its group, with the focus when the file in front there had it, and without it when the focus is in another group Nothing was inserted. Open that file and run the command again
No problem link found LeetCode: Open Problem in Browser or LeetCode: Copy Problem Link found no address: no open file starts with the docstring of a problem with its URL: line — leetcode.showHeader is off, or the docstring stands under imports —, and the extension has fetched no problem since VS Code loaded it. Nothing was asked of LeetCode Fetch a problem first, or open a file that starts with such a docstring
Problem link copied to the clipboard LeetCode: Copy Problem Link wrote to the clipboard the address that follows in the message Nothing to fix
Could not open the link in a browser LeetCode: Open Problem in Browser handed the address to VS Code, which did not open it Open the address in a browser yourself
Error: and then VS Code's message, from one of the two link commands or from LeetCode: Show Hints The browser could not be opened for the address, or the clipboard could not be written. From LeetCode: Show Hints: VS Code's progress notification or its list failed Nothing was opened, copied or shown. Try again
No problem found to show hints for LeetCode: Show Hints found no problem to ask about: no open file starts with the docstring of a problem with its URL: line — leetcode.showHeader is off, or the docstring stands under imports —, and the extension has fetched no problem since VS Code loaded it. Nothing was asked of LeetCode Fetch a problem first, or open a file that starts with such a docstring
No hints to show LeetCode: Show Hints asked LeetCode for the hints of the problem the message names, and LeetCode lists none for it Nothing to fix
Error: and then LeetCode has no problem "…", LeetCode's answer about the hints of "…" has an unexpected shape or another of LeetCode's messages above, from LeetCode: Show Hints The hints could not be fetched. The first: LeetCode has no problem by that name — the URL: line of the active file was written by hand, or the problem was removed or renamed. The second: LeetCode's API changed in a way this version does not know. Another message: the request failed, as it can for a fetched problem For a failed request, see that message's row above. For a problem LeetCode no longer has: fetch the problem again by its title, then run the command on that file. For an answer of an unexpected shape: update the extension
Run Examples needs a Python file open in the editor LeetCode: Run Examples found no active editor Open the Python file of your solution and run the command again
Run Examples runs Python alone LeetCode: Run Examples was run on a file that is not Python Open the Python file of your solution
Run Examples runs a file on disk LeetCode: Run Examples was run on a file never saved, one of a remote or virtual workspace, or one whose save failed Save the file to a folder on this machine
No LeetCode problem found in the active file, from LeetCode: Run Examples LeetCode: Run Examples was run on a file that does not start with the docstring of a problem with its URL: line; the problem fetched last is not used in its place. Nothing was asked of LeetCode Fetch the problem into the file first
The examples of "…" cannot be run LeetCode: Run Examples cannot run this problem's examples; the message says why: a description of its method, or of the class of a design problem, the extension does not read, a type it cannot build (a method that returns nothing where LeetCode names no argument it changes, void, among them), no example, examples that do not give every parameter a value, a value it cannot read or not of its type, or not one output per example Run the examples on LeetCode
Error: and then LeetCode has no problem "…", LeetCode's answer about the examples of "…" has an unexpected shape, is a LeetCode Premium problem or another of LeetCode's messages above, from LeetCode: Run Examples The examples could not be fetched: LeetCode has no problem by the name of the file's URL: line (written by hand, or the problem was renamed), LeetCode's API changed, the problem is for subscribers alone, or the request failed. Error: and another message: the script could not be written or Python not started For a failed request, see that message's row above. For a problem LeetCode no longer has: fetch it again by its title into the file. Otherwise update the extension, or report the message
Python could not be started, in the Output channel LeetCode: Run Examples could not start the interpreter the message names Install Python 3, or set python.defaultInterpreterPath to one
Python was stopped after, in the Output channel The examples did not finish in 10 seconds: an endless loop, or a solution far too slow Look for a loop that does not end
Python ended by the signal or Python ended with exit code, in the Output channel Python ended before it reported: it crashed, ran out of memory, or is not Python 3. What it wrote to its error output follows Check the interpreter's version; the lines below the message say more
ERROR the file … could not be imported or has no class, in the Output channel (on the Debug Console from LeetCode: Debug Examples) Your file raises on import (a syntax error, a missing module), or defines no class of the name the message gives: Solution, or for a design problem its own class (LRUCache) Fix the file; the message ends with the last line of the traceback
pip install sortedcontainers, at the end of a FAIL or ERROR line, in the Output channel (on the Debug Console from LeetCode: Debug Examples) Your solution uses SortedList, SortedDict or SortedSet, of the package sortedcontainers, and the interpreter running the examples cannot import it: the package is not installed for it, or its install is broken Install it for that interpreter (pip install sortedcontainers), then run the command again. The extension itself does not need the package
Debug Examples needs a Python file open in the editor LeetCode: Debug Examples found no active editor Open the Python file of your solution and run the command again
Debug Examples debugs Python alone LeetCode: Debug Examples was run on a file that is not Python Open the Python file of your solution
Debug Examples debugs a file on disk LeetCode: Debug Examples was run on a file never saved, one of a remote or virtual workspace, or one whose save failed Save the file to a folder on this machine
Debug Examples needs the Python extension LeetCode: Debug Examples found neither the Python extension nor its Python Debugger. Nothing was asked of LeetCode Press Install Python Extension, or install it from the Extensions view, then run the command again
No LeetCode problem found in the active file LeetCode: Debug Examples was run on a file that does not start with the docstring of a problem with its URL: line. Nothing was asked of LeetCode Fetch the problem into the file first
The examples of "…" cannot be debugged LeetCode: Debug Examples cannot run this problem's examples, for the reasons of Run Examples' row above Debug the examples on LeetCode
The debugger did not start LeetCode: Debug Examples asked VS Code to debug the examples and VS Code did not start the session: the Python Debugger is disabled, or no interpreter is selected Enable the Python extension and its Python Debugger, select an interpreter (Python: Select Interpreter), and run the command again
Error: and then one of LeetCode's messages above, from LeetCode: Debug Examples The examples could not be fetched, as for Run Examples. Error: and another message: the script could not be written or the debugger not started, or the install failed For a failed request, see that message's row above. Otherwise report the message
No folder to put the problem file in No folder is open in VS Code and leetcode.workspaceFolder is empty or relative. Nothing was asked of LeetCode Open a folder in VS Code, or set leetcode.workspaceFolder to an absolute path
This problem has no slug, so there is no name for its file LeetCode's problem list gave the problem without a slug Pick another problem, and report the problem's number
Error: and then one of LeetCode's messages above The problem could not be fetched, or — from LeetCode: Refresh Problem List — the problem list could not be fetched again: the list the extension had is left as it was. Nothing was written See that message's row above
Error: and then another message The file could not be written or opened. The message is VS Code's or the operating system's; EEXIST: file already exists, mkdir names the folder, not the problem file: a file is where the folder should go No problem file was written (its folder may have been made), unless the file could not be opened: the new file is there, so open it yourself
already exists: it was opened, not changed. The problem's file is there already and holds something — or is empty and open with unsaved edits. The command opens it and asks LeetCode for nothing; an empty file with no unsaved edits is filled with the problem instead Nothing to do: your file is as you left it
A folder is where the problem's file should go A folder has the name the problem's file would have. It is not opened, and nothing was asked of LeetCode Rename or move the folder the message names, then run the command again
Autocomplete is slow
  • A search starts 300 ms after you stop typing, then runs over LeetCode's problem list in memory and asks LeetCode for nothing. The exception is the first search of a day, and any typed while it is still on its way: they wait for the list to download first (about 42 requests in a row)
  • The problem list is kept for 24 hours, in the window and in VS Code's storage for the extension. A problem you fetched is kept for 5 minutes, so fetching it again asks LeetCode for nothing
  • An earlier search's answer that arrives after a newer one is dropped: the list keeps the rows of what you typed last
Network errors
  • Check your internet connection
  • LeetCode API may be temporarily unavailable
  • Try again in a few minutes
  • A search that fails reports the cause as a row in the list (Search error, with Could not reach LeetCode … under it) instead of only showing no problems

🤝 Contributing

Contributions are welcome! Here's how:

  1. Fork the repository
  2. Pick an open item in BACKLOG.md, the roadmap: every planned change is an item there, in priority order, with why it matters and when it is done. For something that is not listed yet, open an issue first
  3. Create a feature branch: git checkout -b feature/amazing-feature
  4. Make the change with its tests and run npm run check: it must pass. A change users can see gets a line under Unreleased in CHANGELOG.md
  5. Commit changes: git commit -m 'Add amazing feature'
  6. Push to branch: git push origin feature/amazing-feature
  7. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • LeetCode for providing the problem database
  • VS Code Extension API for the extension framework

Made with ❤️ for the competitive programming community

Install from Marketplace • Report Bug • Request Feature

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft