Every Accepted was paid in blood, sweat, and runtime errors.
Note: This repository is a work in progress. Expect ongoing improvements and refinements!
- Overview
- Features
- Installation
- Quick Start
- Usage
- File/Folder Structure
- Best Practices
- Code Quality: pre-commit Hooks
- Contributing & Support
- License
- Citation
Scars of LeetCode is an automation-driven workflow and knowledge base for mastering LeetCode problems. It helps you:
- Organize and document solutions
- Generate high-quality spaced-repetition flashcards
- Track your progress
- Integrate with Anki for efficient review
This project is ideal for learners, interview preppers, and anyone who wants to build a deep, recallable understanding of algorithms and data structures.
- Effortless problem management and documentation
- Automated, evidence-based Anki flashcard generation
- Seamless integration with Anki (including WSL support)
- A single source of truth for all your LeetCode learning
- Automated code quality, security, and dependency checks
Prerequisites:
- Python 3.8+
- pip
- pre-commit (for code quality)
- Anki with AnkiConnect (for flashcard import)
Setup:
git clone https://github.com/scarowar/scars-of-leetcode.git
cd scars-of-leetcode
pip install pre-commit
pre-commit install
# (Optional) Install other dependencies as needed
Scars of LeetCode is an automation-driven workflow for mastering LeetCode problems, generating high-quality spaced-repetition flashcards, and tracking your progress. It is designed for power users who want:
- Effortless problem management and documentation
- Automated, evidence-based Anki flashcard generation
- Seamless integration with Anki (including WSL support)
- A single source of truth for all your LeetCode learning
Use the new-problem.sh
script to scaffold a new problem:
./new-problem.sh <problem_number> <problem_slug> <neetcode_150>
# Example:
./new-problem.sh 21 merge-two-sorted-lists true
<problem_number>
: The LeetCode problem number (e.g., 21)<problem_slug>
: The LeetCode slug (e.g., merge-two-sorted-lists)<neetcode_150>
: 'true' if part of NeetCode 150, else 'false'
This creates a folder under problems/
with:
- A ready-to-edit
README.md
(with all required sections) - A starter
solution.py
- Automatic update of the main tracker in
problems/README.md
Edit the generated README.md
and solution.py
for your problem. Follow the template for concise, memory-friendly notes. The tracker will always reflect your current progress.
For each problem, generate a cards.json
(using the provided prompt and your README/solution). Place it in the problem's folder.
To merge all cards and import them into Anki:
python3 scripts/create_import_anki_flashcards.py
Prompts in prompts/
ensure your documentation and flashcards are world-class:
autofill-problem-readme.txt
: Guidance for writing the perfect problem README, focusing on intuition, approach, complexity, and key notes. Use this as a reference or with LLMs to auto-generate your README.create-update-anki-json.txt
: The gold standard for generating Anki flashcards from your README and solution. Cards are designed for active recall, cloze deletions, and spaced repetition. Use this prompt with LLMs to generate acards.json
for each problem.
For each problem, generate a cards.json
(using the above prompt and your README/solution). Place it in the problem's folder.
To merge all cards and import them into Anki:
python3 scripts/create_import_anki_flashcards.py
This script will:
- Merge all
cards.json
files into a master deck (anki/scars-of-leetcode.json
) - Prevent duplicate cards
- Add the
NeetCode150
tag automatically if the problem is part of NeetCode 150 - Import all cards into your Anki deck via AnkiConnect
Prerequisite: You must have the AnkiConnect add-on installed in your Anki desktop app.
For WSL users:
- Open Anki on Windows.
- Go to
Tools
→Add-ons
→ select AnkiConnect →Config
. - Change the config to:
{ "webBindAddress": "0.0.0.0" }
- Restart Anki.
This allows the Python script in WSL to connect to Anki running on Windows.
problems/
— Each problem gets its own folder withREADME.md
,solution.py
, andcards.json
scripts/create_import_anki_flashcards.py
— Merges and imports all flashcards into Ankianki/scars-of-leetcode.json
— Master deck (auto-generated)prompts/
— LLM prompts for README and flashcard generationnew-problem.sh
— Script to scaffold new problems and update the tracker
- Always use the provided prompts for README and flashcard generation for consistency and quality.
- Run the Python script regularly to keep your Anki deck up to date.
- Use the NeetCode 150 flag accurately for tagging and filtering.
- Review the generated tracker in
problems/README.md
for your progress overview.
This repository uses pre-commit to ensure code quality, security, and documentation standards. Hooks are run automatically before every commit to help you ship your best work!
Checks include:
- Python formatting with Black
- Linting and autofix with Ruff
- Security scanning with Bandit and Gitleaks (detects secrets!)
- Markdown linting for
README.md
and docs - YAML, JSON, and whitespace checks
- Various best-practice and safety checks
Setup:
- Install pre-commit (once):
pip install pre-commit
- Install the hooks:
pre-commit install
- (Optional) Run on all files:
pre-commit run --all-files
See .pre-commit-config.yaml
for details and customization.
Contributions, suggestions, and improvements are welcome! Please open an issue or PR. By contributing, you agree that your contributions will be licensed under the GNU General Public License v3.0. See CONTRIBUTING.md for details.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
If you use or reference this project in your research, blog, or elsewhere, please cite it as:
scarowar, "Scars of LeetCode", GitHub, https://github.com/scarowar/scars-of-leetcode
- Open an issue for help, suggestions, or bug reports
- See CONTRIBUTING.md for how to get involved
- Please review our Code of Conduct and Security Policy
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Happy grinding — and may your scars become your strength!