Quick links: Discussions • Issues • Pull requests
A local-run algorithm coding practice system that lets you browse, code, and test problems 100% offline—perfect for planes, cruises, or any no-internet scenario. Features WASM-based browser-side code execution for JavaScript, TypeScript, and Python.
- Node.js 18+ (Download here)
- Any modern web browser
Note: Internet is only required for the initial setup and build. Once built, the application works completely offline.
For the best offline experience, download the pre-built desktop application:
| Platform | Download |
|---|---|
| macOS (Apple Silicon) | Algorithm-Practice-*-macOS-arm64.dmg |
| macOS (Intel) | Algorithm-Practice-*-macOS-x64.dmg |
| Windows (Installer) | Algorithm-Practice-*-Windows-Setup.exe |
| Windows (Portable) | Algorithm-Practice-*-Windows-Portable.exe |
| Linux (AppImage) | Algorithm-Practice-*-Linux.AppImage |
| Linux (Debian/Ubuntu) | Algorithm-Practice-*-Linux.deb |
| Linux (Fedora/RHEL) | Algorithm-Practice-*-Linux.rpm |
⚠️ macOS Users: If you see "App is damaged and can't be opened", run this command in Terminal:xattr -cr "/Applications/Algorithm Practice.app"
Alternatively, you can build the desktop app yourself:
# macOS
npm run dist:mac
# Windows
npm run dist:win
# Linux
npm run dist:linuxSee DESKTOP-APP-GUIDE.md for detailed build instructions.
# Double-click or run in terminal
start-local.batNon-interactive usage (CI or automation):
# Accept defaults and copy from .env.example if present
start-local.bat --yes
# Or set an environment variable (PowerShell)
set START_LOCAL_NONINTERACTIVE=1 && start-local.bat# Make executable (first time only)
chmod +x start-local.sh
# Run the startup script
./start-local.shThe scripts will automatically:
- Check Node.js installation
- Install dependencies (npm install) - Requires internet
- Build the application (npm run build) - Requires internet
- Start the local server
Then open http://localhost:3000 in your browser!
Note: After the initial build, you can use the application offline without rebuilding.
# Clone the repository
git clone https://github.com/zxypro1/OfflineLeetPractice.git
cd OfflineLeetPractice
# Install dependencies - Requires internet
npm install
# Build for production - Requires internet
npm run build
# Start the server (works offline)
npm start- Local Problem Library: 10+ classic algorithm problems included
- AI Problem Generator: Generate unlimited custom problems with various AI providers
- WASM Code Execution: Browser-side execution for JavaScript, TypeScript, and Python
- Monaco Code Editor: VS Code-like editing experience
- Instant Testing: Run tests immediately with detailed results
- Performance Metrics: Execution time tracking
- Dynamic Problem Management: Add/edit problems without rebuilding
- Desktop App: Cross-platform Electron app (Windows, macOS, Linux)
| Language | Status | Implementation |
|---|---|---|
| JavaScript | ✅ Supported | Native browser execution |
| TypeScript | ✅ Supported | TypeScript compiler transpilation |
| Python | ✅ Supported | Pyodide (CPython WASM) |
Note: All code execution happens in the browser using WebAssembly, no server-side execution required.
- Custom Problem Creation: Describe what you want to practice
- Complete Solutions: Each problem includes working reference solutions
- Comprehensive Testing: Auto-generated test cases including edge cases
- Instant Integration: Problems automatically added to your local library
- Browse Problems: View the problem list with difficulty and tags
- Select a Problem: Click on any problem to open the detail page
- Choose Language: Select JavaScript, TypeScript, or Python
- Code Your Solution: Use the Monaco editor (supports autocomplete, syntax highlighting)
- Run Tests: Click "Submit & Run Tests" to execute your code
- View Results: See test results with execution time
- Access AI Generator: Click the "AI Generator" button on the homepage
- Describe Your Need: Enter what type of problem you want
- Generate Problem: AI creates a complete problem with test cases and solutions
- Practice Immediately: Generated problem is auto-added to your library
You can configure AI providers through the settings page, which is accessible in both desktop and web modes:
- In Desktop Mode: Access via the "Settings" button on the loading screen or through the application menu
- In Web Mode: Navigate to
/settingspath (e.g., http://localhost:3000/settings)
The settings page allows you to configure all supported AI providers:
- DeepSeek Cloud Service
- OpenAI
- Qwen (通义千问)
- Claude
- Ollama (Local)
Configuration is saved to your user directory in desktop mode (~/.offline-leet-practice/config.json) or simulated in web mode. See AI_PROVIDER_GUIDE.md for detailed instructions.
To use the AI problem generator, you can configure any of these AI providers (or multiple):
If no .env file exists when you run the provided startup scripts (start-local.sh or start-local.bat), the script will detect this as a first-time startup and offer to interactively configure AI features for you.
DEEPSEEK_API_KEY=your_deepseek_api_key_hereOPENAI_API_KEY=your_openai_api_key_hereQWEN_API_KEY=your_qwen_api_key_hereCLAUDE_API_KEY=your_claude_api_key_hereOLLAMA_ENDPOINT=http://localhost:11434
OLLAMA_MODEL=llama3See AI_PROVIDER_GUIDE.md for more detailed configuration instructions!
- Manual Addition: Use the "Add Problem" page for custom problems
- JSON Import: Upload or paste problem data in JSON format
- Direct Edit: Modify
public/problems.jsonfor immediate changes (no rebuild needed)
- Frontend: React 18 + Next.js 13 + TypeScript
- UI Framework: Mantine v7 (Modern React components)
- Code Editor: Monaco Editor (VS Code engine)
- Code Execution: WASM-based browser execution
- JavaScript: Native browser
Functionconstructor - TypeScript: TypeScript compiler (CDN)
- Python: Pyodide (CPython compiled to WASM)
- JavaScript: Native browser
- Desktop App: Electron
OfflineLeetPractice/
├── pages/ # Next.js pages and API routes
│ ├── api/
│ │ ├── problems.ts # Problem data API
│ │ ├── generate-problem.ts # AI problem generation API
│ │ └── add-problem.ts # Manual problem addition API
│ ├── problems/[id].tsx # Problem detail page
│ ├── generator.tsx # AI Generator page
│ ├── add-problem.tsx # Manual problem addition page
│ └── index.tsx # Homepage
├── src/
│ ├── components/ # React components
│ │ ├── CodeRunner.tsx # Code editor and test runner
│ │ └── ...
│ ├── hooks/
│ │ └── useWasmExecutor.ts # WASM code execution hook
│ └── services/ # Service modules
├── problems/
│ └── problems.json # Local problem database
├── electron-main.js # Electron main process
├── electron-builder.config.js # Desktop app build config
├── start-local.bat # Windows startup script
├── start-local.sh # Unix startup script
└── AI_PROVIDER_GUIDE.md # AI Provider configuration guide
The application supports adding/modifying problems in offline environments without rebuilding!
- Edit the Problem Database: Open
public/problems.jsonin your built application folder - Add Your Problem: Follow the JSON format (see
MODIFY-PROBLEMS-GUIDE.mdfor details) - Save and Refresh: Changes take effect immediately!
Example: Add a new problem by editing public/problems.json:
{
"id": "reverse-string",
"title": {
"en": "Reverse String",
"zh": "反转字符串"
},
"difficulty": "Easy",
"tags": ["string"],
"description": {
"en": "Write a function that reverses a string.",
"zh": "编写一个函数来反转字符串。"
},
"template": {
"js": "function reverseString(s) {\n // Your code here\n}\nmodule.exports = reverseString;"
},
"tests": [
{ "input": "[\"h\",\"e\",\"l\",\"l\",\"o\"]", "output": "[\"o\",\"l\",\"l\",\"e\",\"h\"]" }
]
}See MODIFY-PROBLEMS-GUIDE.md for complete instructions!
We welcome contributions! Areas for improvement:
- More Problems: Add classic algorithm challenges
- Enhanced Features: Better performance analytics
- UI Improvements: Enhanced user experience
MIT License - Feel free to use, modify, and distribute!
Happy Coding at 30,000 feet!