LeetCode Runner (Java) for VS Code
Pick a LeetCode problem, write Solution.java, then test and submit without leaving VS Code.
Cases that fail during Submit are saved automatically and run with every later Test.
After a submit, your submission page opens in the browser so you can compare with other solutions.
Plain JavaScript, no dependencies, no build step.
Install
From the .vsix file (VS Code: Extensions view, ... menu, Install from VSIX...), or:
code --install-extension leetcode-runner-0.1.0.vsix
Run from source: open this folder in VS Code and press F5.
Use it
- Open a folder for your practice (the extension keeps
Solution.java there).
- Click the
</> icon in the Activity Bar, or the status bar item, or press Ctrl+Shift+P and type LeetCode.
- Pick Problem: enter a number, slug or URL, or choose Next / Previous / Today's daily.
- Write your solution in
Solution.java.
- Click Test or Submit (CodeLens above
class Solution, the editor title bar, or the sidebar).
- First time: Login / Account asks for your
LEETCODE_SESSION and csrftoken cookies
(log in at leetcode.com, press F12, Application/Storage, Cookies). They are stored encrypted in
VS Code's secret storage, never in your project.
| Command |
What it does |
| LeetCode: Pick Problem |
Loads a problem and replaces Solution.java with its starter code |
| LeetCode: Show Description |
Description in a side panel |
| LeetCode: Test |
Runs examples + saved failed cases on LeetCode |
| LeetCode: Submit |
Real submission, verdict panel, opens your submission page |
| LeetCode: Login / Account |
Sign in, check session, sign out |
| LeetCode: Clear Failed Cases |
Removes saved failing cases for the current problem |
Files created in your folder: Solution.java, tests/<number>-<slug>.json (saved failed cases) and
.lcrunner/problem.json (current problem). They are the same files the Java and Python command-line
editions use, so you can switch between them.
Picking a new problem overwrites Solution.java. Earlier saved versions are in the editor's Timeline view.
Settings
leetcodeRunner.confirmSubmit (default on): ask before submitting.
leetcodeRunner.autoOpenSubmission (default on): open the submission page after Submit.
Build the .vsix yourself
npm install
npm run package
Notes
This uses LeetCode's unofficial web endpoints, so it may break if they change, and Cloudflare can
sometimes block requests (you'd see a 403). Automated submission may be restricted by LeetCode's terms.
Set publisher in package.json to your own publisher id before publishing to a marketplace.