LeetGrind for VS Code
Your ACM LeetGrind sheets inside the editor: read problems, run tests and submit to LeetCode without leaving VS Code. Works in VS Code, Cursor, Windsurf and VSCodium.
Getting started
- Sign in to LeetGrind. Open the LeetGrind view in the activity bar and press Sign in. Your browser opens LeetGrind; press Allow and the editor finishes signing in. On a remote machine or in the browser, use Sign in with a code and paste the code the site shows.
- Connect LeetCode. Run LeetGrind: Connect LeetCode account. On leetcode.com, while signed in, open DevTools → Application → Cookies →
https://leetcode.com, copy the value of LEETCODE_SESSION and paste it. A whole Cookie header or "Copy as cURL" works too. It has to be the LeetCode account your LeetGrind profile uses.
- Solve. Pick a problem in the sidebar. Your solution file opens with the description beside it. Use Run and Submit above the code (or
Ctrl+Alt+R / Ctrl+Alt+S).
After an accepted submission the extension asks LeetGrind to sync, so the solve shows on your sheet straight away.
Your LeetCode session stays on your machine
The LEETCODE_SESSION cookie is kept in the editor's secret storage and only ever sent to leetcode.com. It is never sent to LeetGrind. LeetCode sessions last about two weeks; when yours runs out, the sidebar tells you and you paste a fresh one. Signing out of leetcode.com in your browser also ends it.
Solution files
Solutions go in a leetgrind folder in your workspace (or ~/leetgrind), named like 1.two-sum.py. Only the code between @lc code=start and @lc code=end is sent. Files made by the original LeetCode extension work too.
Run uses LeetCode's example cases. To try your own, use Test cases above the code: it opens testcases/<problem>.txt, one value per line, cases one after another.
Settings
| Setting |
Default |
|
leetgrind.language |
python3 |
Language for new solution files |
leetgrind.solutionsFolder |
(workspace)/leetgrind |
Where solution files go |
leetgrind.siteUrl |
https://leetgrind.acm-ascis.app |
Only for local development |
When something goes wrong
- "LeetCode turned the request away": your LeetCode session has expired. Paste a fresh
LEETCODE_SESSION.
- "LeetCode asks you to wait": LeetCode limits how quickly you can run code, on the website too. The extension waits and retries by itself.
- The editor didn't open after pressing Allow: copy the code from the page and run LeetGrind: Sign in with a code.
- You can sign an editor out from your LeetGrind profile under Code editors.
Development
cd extension
npm install
npm run build # or: npm run watch
npm test
npm run package # makes leetgrind-<version>.vsix
Press F5 with the extension folder open to try it in an Extension Development Host. Point leetgrind.siteUrl at http://localhost:3000 to use a local site.