🧩 LeetCode Problem Fetcher
Instantly fetch LeetCode problems into your editor with smart autocomplete
Installation •
Features •
Usage •
Demo •
Development
A powerful Cursor/VS Code extension that automatically fetches LeetCode problem descriptions and Python3 starter code, then inserts them directly into your editor as clean, readable docstrings.
✨ Features
| Feature |
Description |
| 🔍 Smart Autocomplete |
Type a number prefix and see all matching problems (e.g., "8" → 8, 80, 81, 82...) |
| 📝 Clean Docstrings |
Problem descriptions formatted as Python triple-quote docstrings |
| 💻 Starter Code |
Automatically includes the default Python3 code template |
| 🌳 Auto-Uncomment Classes |
TreeNode, ListNode, etc. are automatically uncommented and ready to use |
| 🎯 Prefix Search |
Search by problem number, title, or "number. title" format |
| 🚀 Fast & Cached |
Uses LeetCode's GraphQL API with 5-minute caching for instant repeated searches |
| ✂️ No Examples Clutter |
Automatically removes verbose example sections |
🚀 Usage
Keyboard Shortcut
| Platform |
Shortcut |
| Mac |
Cmd+D+L |
| Windows/Linux |
Ctrl+D+L |
Quick Start
- Open any file in Cursor/VS Code (preferably a
.py file)
- Press the shortcut or open Command Palette (
Cmd+Shift+P)
- Run:
Fetch LeetCode Problem
- Search for a problem using any of these formats:
- By number:
841
- By prefix:
8 (shows 8, 80, 81, 82, ..., 800, 801, ...)
- By title:
Two Sum
- Combined:
1. Two Sum
- Select from the autocomplete dropdown
- Done! The problem is inserted at the top of your file
Search Examples
| Input |
Results |
1 |
Problem 0001, 0010, 0011, 0012, ..., 0100, 0101, ... |
84 |
Problem 0084, 0840, 0841, 0842, ... |
841 |
Problem 0841 |
Two Sum |
Problems with "Two Sum" in the title |
841. Keys |
Problem 841 (if title matches) |
📸 Demo
After fetching problem 450. Delete Node in a BST, your file will contain:
"""
Delete Node in a BST
LeetCode 450 - Difficulty: Medium
Given a root node reference of a BST and a key, delete the node with the given key in the BST.
Return the root node reference (possibly updated) of the BST.
Basically, the deletion can be divided into two stages:
1. Search for a node to remove.
2. If the node is found, delete the node.
Constraints:
- The number of nodes in the tree is in the range [0, 10^4].
- -10^5 <= Node.val <= 10^5
- Each node has a unique value.
- 'root' is a valid binary search tree.
- -10^5 <= key <= 10^5
"""
# 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
class Solution:
def deleteNode(self, root: Optional[TreeNode], key: int) -> Optional[TreeNode]:
✨ Key Features Shown:
- Clean docstring: Problem description without verbose examples
- Auto-uncommented
TreeNode: Class definition is ready to use (not commented out!)
- Parameters marked:
'root' is quoted for clarity
🎯 Why This Extension?
Before (Manual Process)
- Open LeetCode website
- Find the problem
- Copy the description
- Format it as comments
- Copy the starter code
- Paste everything into your editor
- Time: 2-3 minutes per problem
After (With This Extension)
- Press
Cmd+L Cmd+E → Search → Select
- Time: 5 seconds
Perfect for:
- 📚 Daily LeetCode practice
- 🎓 Interview preparation
- 📖 Building a solutions repository
- ⚡ Speed coding sessions
⚙️ How It Works
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ User Input │ ──▶ │ LeetCode API │ ──▶ │ Format & │
│ "841" │ │ (GraphQL) │ │ Insert │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
Prefix Match Fetch Problem Triple-quote
8, 80, 81... Description + Docstring +
Python3 Code Starter Code
- Parse Input: Detects if input is a number prefix, title, or combined format
- Smart Search: Scans LeetCode's problem database with intelligent pagination
- Fetch Details: Uses GraphQL API to get problem content and code snippets
- Clean & Format: Removes examples, converts HTML to clean text
- Insert: Places formatted docstring + code at cursor position
🛠️ Development
Project Structure
leetcode-extension/
├── src/
│ ├── extension.ts # Extension entry point & UI logic
│ └── leetcodeCrawler.ts # LeetCode API integration
├── out/ # Compiled JavaScript
├── package.json # Extension manifest
├── tsconfig.json # TypeScript configuration
├── CHANGELOG.md # Version history
├── LICENSE # MIT License
└── README.md # You are here!
Building
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Watch mode (auto-compile on save)
npm run watch
# Package as VSIX
npm run package
Testing Locally
- Open the project in Cursor/VS Code
- Press
F5 to launch Extension Development Host
- In the new window, run
Fetch LeetCode Problem
📋 Requirements
- Editor: Cursor IDE or VS Code 1.74+
- Network: Internet connection to fetch problems
❓ Troubleshooting
Problem not found
- Verify the problem number exists on LeetCode
- Check your internet connection
- Premium-only problems may not be accessible
Autocomplete is slow
- The extension needs to fetch problem lists from LeetCode
- First search may take 1-2 seconds
- Subsequent searches are faster
Network errors
- Check your internet connection
- LeetCode API may be temporarily unavailable
- Try again in a few minutes
🤝 Contributing
Contributions are welcome! Here's how:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit changes:
git commit -m 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Open a Pull Request
Ideas for Contributions
- [ ] Support for other languages (Java, C++, JavaScript, etc.)
- [ ] Problem difficulty filtering
- [ ] Favorites/bookmarks
- [ ] Solution templates
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
Made with ❤️ for the competitive programming community
Install from Marketplace •
Report Bug •
Request Feature