Skip to content

richardkkk/leetcode-solution-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Solution Manager

中文说明

A small command-line tool for creating, organizing, and tracking personal LeetCode solution files.

Why I Built This

I am used to writing and debugging coding solutions locally. As my collection grew, it became harder to find, review, and revisit solutions, even after I regularly organized them into separate files.

The motivation for building this tool was to handle common local tasks with simple one-line commands: create or remove a problem file, check project data, and track progress. The goal is to keep the workflow focused on writing and running solutions locally.

When a user explicitly runs a command that needs problem information, this tool sends requests to LeetCode endpoints to generate local learning files. It does not run in the background or distribute problem statements, official code templates, test cases, or other platform content with this public repository.

This is an unofficial, independent project for personal learning management. It is not affiliated with, endorsed by, sponsored by, or approved by LeetCode. Users are responsible for reviewing and complying with applicable platform terms and policies, and for their own access and use.

Features

  • Create a Python solution file from a LeetCode problem number.
  • Save problem metadata in problems.json and generate a dated progress.md report.
  • Mark one or more registered problems as solved.
  • Refresh generated descriptions and local test blocks without replacing your solution code.
  • Archive, remove, or check solution records.

Scope

The project currently focuses on LeetCode. Support for additional coding platforms may be considered in the future based on real user needs.

Requirements

  • Python 3.10 or newer.
  • No third-party packages are required.

Quick start

git clone https://github.com/richardkkk/leetcode-solution-manager.git
cd leetcode-solution-manager
python manage.py add 189
python manage.py solve 189

The first command creates a file under solutions/ and records the problem in a local problems.json. The second marks it as solved and regenerates progress.md. In progress.md, each problem title links to its local solution file, and the accompanying Problem link opens the corresponding LeetCode page for quick review.

If problem metadata cannot be retrieved, provide an English title:

python manage.py add 189 "Rotate Array"

Local data

By default, your personal problems.json, progress.md, and solution files are intentionally ignored by Git. problems.example.json shows the data-file shape without including any personal records.

If you want to track any of this data in your own repository, edit .gitignore and remove the corresponding rule from the Personal learning data section. For example, remove progress.md to commit only your progress report, or remove solutions/*.py to commit your solution files. The default rules are intended for this reusable public repository, not as a restriction on your own workflow.

Commands

For the full options of any command, run python manage.py <command> --help.

Add a problem

python manage.py add 189

The command attempts to retrieve the title, difficulty, and topic tags from LeetCode and uses today's date as the creation date. When metadata is available, it also generates a Python 3 method template, problem description, examples, explanation, constraints, and the first example that can be safely converted to a local test. Images and complex mathematical expressions are skipped.

The problem URL is saved in problems.json, the solution-file header, and progress.md. Creating a problem does not mark it as solved or add it to progress.md.

If the request cannot be completed, provide an English title to continue:

python manage.py add 189 "Rotate Array"

Running add for an existing problem is rejected so that an existing solution is never overwritten. You may optionally provide --slug only when you need to override the URL slug inferred from the title.

Mark problems as solved

python manage.py solve 169 189
python manage.py solve 189 --date 2026-07-16
python manage.py solve 189 --date 2026-07-16 --force

The default solved date is today. An existing solved date is preserved unless you explicitly use --force. solve always rebuilds progress.md.

Refresh one problem

python manage.py refresh 380

Refresh updates only marked, generated regions. It does not replace your Solution implementation. When a file cannot be safely updated, a preview is written to refresh_previews/ for manual review.

Remove a problem

python manage.py remove 189
python manage.py remove 189 --delete --yes
python manage.py remove 189 --keep-file --yes

By default, remove moves the solution file to archive/, removes its record, and updates the progress report. Use --delete only when you intend to permanently delete that file, or use --keep-file to remove only the record. The command asks for confirmation unless you explicitly add --yes.

Check project consistency

Creating or deleting files directly in solutions/ does not update the saved records or progress report. Run:

python manage.py check

The command reports registered files that are missing, unregistered solution files, duplicate or malformed problem-number prefixes, and a progress.md file that is out of date. There is no background file watcher, so run check after manual changes. For ordinary use, prefer add and remove to keep the files and records in sync.

Rebuild the progress report

Use progress when you only need to regenerate the report from problems.json:

python manage.py progress

License

Released under the MIT License.

About

A CLI for creating, organizing, and tracking personal LeetCode solution files.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages