LitCode 🔥
The modern, local-first LeetCode companion for VS Code
LitCode is an all-in-one VS Code extension crafted for fast, frictionless, local-first algorithmic problem solving. Practice thousands of LeetCode problems directly from your editor with zero mandatory login, run test cases instantly on your own machine without server lag, track curated study roadmaps (Striver's SDE Sheet, NeetCode 150, Blind 75), visualize complex data structures, and get gentle Socratic hints from an AI coach.
📑 Table of Contents
✨ Features
🚀 Guest-First & Zero Setup
- No Sign-In Required: Browse problems, daily challenges, and curated study plans immediately after installing.
- Offline Capable: Cache problem descriptions, test cases, and solution templates locally.
- Local Persistence: Bookmarks and solved statuses are automatically tracked on your machine.
- Daily Coding Challenge: Instantly view and load today's official LeetCode Daily Challenge with one click.
- Curated Study Plans: Built-in tracking for the most popular interview preparation sheets:
- Striver's SDE Sheet (191 core interview questions)
- NeetCode 150 (comprehensive pattern-based curriculum)
- Blind 75 (essential DSA foundations)
- Custom Study Sheets: Create, manage, and delete your own custom question sets.
- One-Click Offline Mode: Download entire study plans or your saved bookmarks for offline use (e.g. while traveling or on airplane mode).
- Instant Problem Search: Search across 3,000+ LeetCode problems by name, number, or slug directly in the VS Code QuickPick (
Ctrl+Shift+P -> LeetCode: Search Problems).
🖥️ Companion Problem Webview
- Opens automatically beside your active solution editor (
ViewColumn.Beside).
- Rich Rendering: Beautifully formatted problem statements, difficulty badges, category tags, constraints, and hints.
- Interactive Test Runner UI: View sample test cases, add your own custom inputs, run tests, and inspect stdout and execution times.
- Direct Submission: Submit your completed solution to LeetCode with real-time submission verdicts (Accepted, Wrong Answer, TLE, etc.).
⚡ Local Multi-Language Test Runner
- Test your code locally on your machine without relying on LeetCode's remote servers or waiting in execution queues.
- Instant Feedback: Provides execution time in milliseconds, pass/fail status, expected vs. actual output comparisons, and floating-point error tolerance.
- Supported Languages:
- Python 3
- JavaScript (Node.js)
- TypeScript
- C++ (g++ / clang++)
- Java (javac / java)
- Automatic Harness Generation: Includes full local boilerplate for common data structures (
ListNode, TreeNode), stdin/stdout parsing, and function wrapping.
- Remote Fallback: If you do not have a local compiler (e.g., C++ or Java) installed, LitCode can automatically fall back to an online execution engine (Piston API) without interrupting your flow.
🌳 Data Structure Visualizer
- Visualizes test case inputs directly in the companion webview:
- Binary Trees: Renders tree levels, nodes, and parent-child edges in clear SVG diagrams.
- Linked Lists: Visualizes nodes and pointer arrows.
- Arrays: Visualizes array indices and values cleanly.
🤖 Socratic AI Coach
- Practice problem solving without spoiling the answers:
- Progressive Hints: Get tiered assistance (Tier 1: High-level hint, Tier 2: Algorithmic approach, Tier 3: Pseudocode guidance).
- Diagnose Failures: If your local tests fail, ask the coach to analyze your code against the failing test case and highlight the logical flaw.
- Complexity Analysis: Request an asymptotic time and space complexity evaluation (Big-O analysis) for your solution.
- Flexible AI Providers:
- Zero Setup: Uses VS Code's Language Model API (GitHub Copilot) out of the box.
- BYOK (Bring Your Own Key): Connect OpenAI, Google Gemini, Anthropic Claude, or local Ollama instances via standard OpenAI-compatible endpoints.
⏱️ Mock Interview Timer & Strict Mode
- Countdown Timer: Built-in 45-minute (configurable) interview timer displayed directly in your VS Code status bar.
- Timer Controls: Easily pause, resume, and reset the timer.
- Strict Mode: Alerts you if you leave the solution editor or switch windows during the session, enforcing real-world interview focus.
🧠 Spaced Repetition (SRS)
- Solved problems are automatically scheduled for periodic review using the SM-2 spaced repetition algorithm.
- Strengthen weak areas and review patterns at optimal retention intervals before interviews.
☁️ Optional LeetCode Account Sync
- Connect your LeetCode session cookie securely using VS Code's encrypted
SecretStorage.
- Submit directly to LeetCode to record solutions and maintain your official LeetCode streak.
📦 Setup & Prerequisites
Installation
Search for LitCode in the VS Code Extensions view (Ctrl+Shift+X or Cmd+Shift+X) and click Install, or get it from:
Local Language Runtimes
To run tests locally on your machine, ensure the runtime for your preferred language is installed:
| Language |
Requirement |
Verification Command |
Notes / Custom Path Setting |
| Python 3 |
Python 3.8+ |
python --version or python3 --version |
Configurable via leetcode.runner.pythonPath |
| JavaScript |
Node.js 18+ |
node --version |
Uses system Node.js |
| TypeScript |
Node.js 18+ |
node --version |
Transpiled on-the-fly |
| C++ |
g++ or clang++ (C++17+) |
g++ --version |
Auto-detects MinGW/MSYS2 on Windows. Configurable via leetcode.runner.gppPath |
| Java |
JDK 11+ (javac, java) |
javac --version |
Configurable via leetcode.runner.javacPath |
[!TIP]
If a local compiler is missing on your machine, LitCode can automatically use its built-in remote execution fallback (leetcode.runner.remoteFallback) so you can keep solving problems without interruption.
Configuring Solution Directory
By default, LitCode saves your solution files in ~/.leetcode/solutions/<problem-slug>/.
You can change this to any directory (e.g. your own Git repository) in VS Code Settings:
- Open Settings (
Ctrl+, or Cmd+,).
- Search for
leetcode.solutionsDirectory.
- Set your preferred folder path (e.g.,
D:\Code\LeetCode-Solutions or /home/user/leetcode).
Setting up the AI Coach
LitCode provides an AI Coach with two options:
- GitHub Copilot (Default / Zero Config): If you have GitHub Copilot active in VS Code, leave
leetcode.ai.apiKey empty. LitCode will automatically use VS Code's Language Model API.
- Bring Your Own Key (BYOK):
- In VS Code Settings, set
leetcode.ai.apiKey to your API key.
- Set
leetcode.ai.endpoint to your provider endpoint (defaults to https://api.openai.com/v1/chat/completions).
- Set
leetcode.ai.model to your desired model (e.g., gpt-4o-mini, gemini-1.5-flash, or a local model name for Ollama).
Connecting Your LeetCode Account (Optional)
Connecting your account is only required if you want to submit code directly to LeetCode's servers to update your LeetCode profile streak:
- Open your browser and log into LeetCode.
- Open Developer Tools (
F12 or right-click -> Inspect), navigate to the Application (or Storage) tab, and expand Cookies -> https://leetcode.com.
- Copy the values of
LEETCODE_SESSION and csrftoken (or copy the entire Cookie request header from the Network tab).
- In VS Code, press
Ctrl+Shift+P (or Cmd+Shift+P) and run LeetCode: Sign In with LeetCode Cookies.
- Paste your cookie string or credentials when prompted. Your credentials are encrypted safely using VS Code
SecretStorage.
💡 How to Use LitCode
Click the LitCode (Flame 🔥) icon in the VS Code Activity Bar on the left side of your window.
2. Choose a Problem
- Daily Challenge: Click Open Daily Challenge in the sidebar title bar or tree view.
- Study Plans: Expand Curated Study Plans to explore Striver's SDE Sheet, NeetCode 150, or Blind 75.
- Search: Click the Search icon or press
Ctrl+Shift+P and choose LeetCode: Search Problems to search by title, difficulty, or problem number.
3. Write Your Solution
When a problem opens:
- Your solution file is generated in your configured language template (e.g.,
solution.py, solution.cpp, solution.java, solution.ts).
- The Companion Problem Webview opens side-by-side with the problem statement, examples, and constraints.
4. Run Local Tests
- Click the Play (Run Local Tests) button in the editor title bar, or click Run Tests in the companion webview.
- You can add custom test cases in the test cases box.
- LitCode runs the test harness locally and displays exact outputs, expected values, execution time, and stdout.
5. Ask the AI Coach for Guidance
If you are stuck or need an algorithmic sanity check:
- In the companion webview, use the AI Coach buttons:
- Get Hint: Provides progressive Socratic clues without giving away the answer.
- Diagnose Failure: Explains why your code produced unexpected outputs.
- Analyze Complexity: Breaks down time and space complexity in Big-O notation.
6. Practice Under Mock Interview Conditions
- Click the watch icon or run
LeetCode: Start Mock Interview Timer to start a 45-minute countdown in the status bar.
- Run
LeetCode: Toggle Strict Mock Interview Mode to enable alerts if you navigate away from the solution editor.
7. Submit to LeetCode
Once your local test cases pass, click Submit Solution in the editor title bar or webview to submit to LeetCode and receive your official online evaluation.
⚙️ Configuration Settings
Customize LitCode by opening Settings (Ctrl+, or Cmd+,) and filtering by LitCode:
| Setting |
Default |
Description |
leetcode.defaultLanguage |
"python3" |
Default language for newly opened problem solutions (python3, javascript, typescript, cpp, java). |
leetcode.solutionsDirectory |
"" |
Directory where solution files are saved. Defaults to ~/.leetcode/solutions if left empty. |
leetcode.autoOpenCompanionWebview |
true |
Automatically opens the companion problem description webview beside your solution code. |
leetcode.endpoint |
"https://leetcode.com" |
LeetCode endpoint (https://leetcode.com or https://leetcode.cn). |
leetcode.runner.gppPath |
"" |
Path to g++ or clang++ binary (e.g., C:\msys64\ucrt64\bin\g++.exe). Auto-detected if blank. |
leetcode.runner.pythonPath |
"" |
Path to Python binary. Auto-detected from system PATH if blank. |
leetcode.runner.javacPath |
"" |
Path to javac binary. Auto-detected from system PATH if blank. |
leetcode.runner.remoteFallback |
true |
Falls back to remote code execution (Piston API) if a local compiler/runtime is not installed. |
leetcode.runner.remoteEndpoint |
"https://emkc.org/api/v2/piston" |
Piston-compatible API endpoint for remote execution fallback. |
leetcode.ai.apiKey |
"" |
Custom API Key for AI Coach (BYOK). Leave empty to use VS Code Language Model API (GitHub Copilot). |
leetcode.ai.endpoint |
"https://api.openai.com/v1/chat/completions" |
Custom AI endpoint URL (OpenAI, Ollama, Gemini proxy, etc.). |
leetcode.ai.model |
"gpt-4o-mini" |
Model identifier for custom AI provider. |
⌨️ Commands Reference
All commands are accessible via the Command Palette (Ctrl+Shift+P on Windows/Linux, Cmd+Shift+P on macOS):
| Command ID |
Command Palette Title |
Description |
leetcode.openDailyChallenge |
LeetCode: Open Daily Challenge |
Fetches and opens today's LeetCode problem of the day. |
leetcode.searchProblem |
LeetCode: Search Problems |
Fast fuzzy search across 3,000+ problems. |
leetcode.runLocalTests |
LeetCode: Run Local Tests |
Executes sample and custom test cases locally. |
leetcode.submitSolution |
LeetCode: Submit Solution to LeetCode |
Submits solution code to LeetCode for official judgment. |
leetcode.refreshExplorer |
LeetCode: Refresh Explorer |
Reloads study plans, daily challenge, and problem statuses. |
leetcode.changeLanguage |
LeetCode: Change Preferred Language |
Switches default programming language. |
leetcode.addStudyPlan |
LeetCode: Add Study Plan |
Creates a new custom problem study plan. |
leetcode.deleteStudyPlan |
LeetCode: Delete Custom Study Plan |
Deletes a custom study plan. |
leetcode.downloadStudyPlanOffline |
LeetCode: Make Study Plan Available Offline |
Pre-caches all problems in a study plan for offline use. |
leetcode.downloadBookmarksOffline |
LeetCode: Make All Bookmarks Available Offline |
Pre-caches all bookmarked problems for offline use. |
leetcode.toggleBookmark |
LeetCode: Toggle Bookmark |
Stars/unstars the active problem. |
leetcode.toggleSolved |
LeetCode: Toggle Solved Status |
Manually marks a problem as solved or unsolved. |
leetcode.startInterviewTimer |
LeetCode: Start Mock Interview Timer |
Starts the 45-minute mock interview countdown. |
leetcode.toggleInterviewTimer |
LeetCode: Toggle Mock Interview Timer (Pause/Resume) |
Pauses or resumes the active interview timer. |
leetcode.manageInterviewTimer |
LeetCode: Manage Mock Interview Timer (Pause/Resume/Reset) |
Opens timer management options in QuickPick. |
leetcode.resetInterviewTimer |
LeetCode: Reset Mock Interview Timer |
Resets the interview timer back to default duration. |
leetcode.toggleStrictMode |
LeetCode: Toggle Strict Mock Interview Mode |
Toggles window-focus enforcement during timed practice. |
leetcode.signIn |
LeetCode: Sign In with LeetCode Cookies |
Saves your LeetCode session cookies in secure storage. |
leetcode.signOut |
LeetCode: Sign Out |
Removes saved session cookies and logs out. |
❓ FAQ & Troubleshooting
Why did local C++ testing say "g++ compiler not found"?
On Windows, C++ requires g++ or clang++ to be in your system PATH (such as from MSYS2, MinGW-w64, or LLVM). If it is installed in a non-standard directory, set the full path to g++.exe in VS Code Settings:
"leetcode.runner.gppPath": "C:\\msys64\\ucrt64\\bin\\g++.exe"
Alternatively, keep leetcode.runner.remoteFallback set to true to execute tests via the remote runner fallback.
Can I use LitCode without an internet connection?
Yes! LitCode is built local-first:
- When online, right-click any study plan and select Make Study Plan Available Offline (or run
LeetCode: Make All Bookmarks Available Offline).
- Once cached, problem descriptions, metadata, and test cases work entirely offline.
- Test runs execute locally on your own machine without making network requests.
How do I use LitCode with local LLMs (e.g. Ollama)?
Configure your VS Code settings to point to your local Ollama instance:
"leetcode.ai.endpoint": "http://localhost:11434/v1/chat/completions",
"leetcode.ai.apiKey": "ollama",
"leetcode.ai.model": "llama3"
Can I save solutions to a custom Git repository?
Yes! Set leetcode.solutionsDirectory to your local repository directory:
"leetcode.solutionsDirectory": "/path/to/my-leetcode-repo"
LitCode will automatically create and organize folders per problem inside that directory.
📄 License
This extension is licensed under the MIT License.
| |