doocs/leetcode: solutions indexed by algorithm pattern, behind a five-formatter commit gate
🔥LeetCode solutions in any programming language | 多种编程语言实现 LeetCode、《剑指 Offer(第 2 版)》、《程序员面试金典(第 6 版)》题解
At a glance
- What is it?
- A Java-primary repository of LeetCode solutions licensed under CC-BY-SA-4.0, indexed by the technique a problem wants rather than by difficulty, with formatting for five language families routed through a Python bridge. Strong as a reference index, awkward as a project, since no version has been tagged since February 2025 and the root content license leaves source files ambiguous.
- Who is it for?
- doocs/leetcode earns a place in an interview prep rotation for anyone who learns by technique, since the index tells you which pattern a problem wants before you show the code. Skip it if you need difficulty tiers, a judge that runs your submission, or a license that treats source files unambiguously.
- Can I use it commercially?
- Yes, with credit. CC-BY-SA-4.0 allows commercial use as long as you credit the authors and indicate what you changed. It is written for creative content, so check how it applies to any code.
- Is it still maintained?
- Yes. The repository received new commits within the last day.
- What is it written in?
- Mainly Java, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.
Editorial analysis
Five formatters stand between your commit and the repository
Every staged file is routed to the formatter for its language, and that routing table is the most interesting thing in the manifest. Five entries cover five language families:
"lint-staged": {
"*.{js,ts,php,sql,md}": "prettier --write",
"*.py": "node scripts/run-py.js -m black -S",
"*.{c,cpp,java}": "node scripts/run-py.js run_format.py --clang-format",
"*.go": "node scripts/run-py.js run_format.py --gofmt",
"*.rs": "rustfmt --edition 2021"
},Java, the repository's primary language, goes through clang-format by way of a Python wrapper script rather than through an editor setting. Go goes through gofmt by that same route. Rust skips Python altogether and calls rustfmt with edition 2021. Markdown, SQL, PHP, JavaScript, and TypeScript share one Prettier pass, which is why the dependency list carries a Prettier PHP plugin and a SQL plugin. The upside is uniform formatting across languages you may never have installed. The cost is that a Java contributor needs a working Python environment before the first commit, and the SQL plugin exists because the repository runs a database track alongside the algorithm ones.
The Python bridge makes Python a hard requirement for every contributor
Three of the five format routes, plus the site preview, pass through scripts/run-py.js, and the setup script installs what that bridge needs from a pinned requirements file:
node scripts/run-py.js -m pip install -r requirements.txtThat file pins exact versions: black 26.5.1, clang-format 23.1.1, PyYAML 6.0.3, requests 2.34.2, and urllib3 2.8.0. Nothing is left to a range, so a formatter upgrade arrives as a deliberate edit rather than as silent drift. The Python requirement is not limited to Python solutions: the clang-format and gofmt routes are Python entry points, and previewing the rendered site is Python too. If your environment cannot install those five packages, the commit hook fails for reasons that have nothing to do with the solution you wrote.
One flag is worth knowing before you argue with the formatter. The Python route passes -S to black, which is black's option for skipping string normalization, so whitespace inside string literals survives the format pass untouched. That is what keeps padded output blocks and grids readable in the rendered write-ups.
Solutions live in number buckets, and three directories sit outside the index
The main collection is split into four-digit ranges named after the problem number, and every path in the index follows that shape. Problem 34 sits under solution/0000-0099, problem 862 under solution/0800-0899, problem 2305 under solution/2300-2399. Each entry is a directory whose README is the way in, so a problem implemented in several languages lives under one numbered path rather than being split across language folders.
The other books get their own top-level trees: lcof, lcof2, and lcci, holding the two Sword Finger Offer editions and the sixth edition of the coding interview classic. The top-level index links five collections, LeetCode itself, the archive of past weekly contests, and those three book trees. basic/, lcp/, and lcs/ are not in that list, and their subjects are not stated anywhere in the index, so you have to guess from the directory names. The practical consequence is that a reader who navigates strictly by the index never reaches them, and a reader who wants the 剑指 Offer problem set has to leave the LeetCode buckets entirely and start over in a different tree.
The index sorts by algorithm pattern, and the pattern names are in Chinese
Difficulty is not the organizing principle here. The topic sections group problems by the technique that solves them, and the labels are specific: binary search, prefix sums and difference arrays, two pointers, monotonic stack, monotonic queue, string hashing, lowbit bit tricks, multi-source BFS, bidirectional BFS, deque BFS, A* search, the minimum steps model, memoized search, and backtracking with pruning. Problem 0079 Word Search appears under DFS with search order and backtracking, while 0542 01 Matrix appears under multi-source BFS. That is the genuinely useful part of the index, since it tells you what to reach for before you write a line.
It is also the friction for an English reader, because the technique names carry the meaning and they are written in Chinese. An English version is linked at the repository root as README_EN.md, and what that file covers is not visible from the index. Until you can read the labels, you are matching on problem titles and recognising the technique from the code, which inverts the point of a pattern index.
CC-BY-SA-4.0 is a content license, and its reach over source files is unclear
The license is Creative Commons Attribution-ShareAlike 4.0, a content license rather than the permissive software license most code repositories carry. Attribution is required, and the share-alike term reaches derivative works, so a translation or a repackaged set of explanations inherits the same obligation.
Applying that to source files is the awkward part. Creative Commons licenses are written for prose and media, this repository puts one license at the root rather than pairing it with a separate code license, and nothing in the repository listing settles whether the Java, Python, and Go solution files are covered by it. A reader who copies a solution set into an internal handbook, or a training product built on the explanations, inherits an attribution requirement and an open question about the code, which is a legal review rather than a README detail. Everything else about the contributor setup is thorough: CODE_OF_CONDUCT.md, CONTRIBUTING.md, .editorconfig, .clang-format, and commitlint.config.js enforcing conventional commits.
Tags stopped at v0.3.0 in February 2025 while commits kept landing
The release history does not track the content. The three most recent tags are v0.3.0 from February 20, 2025, v0.2.0 from July 24, 2024, and v0.1.9 from January 28, 2022, and the newest of them predates the last push by more than a year and a half. The repository was last pushed on September 27, 2026, so the working tree is current even though no version has been cut for it.
For a content repository this matters less than it would for a library, since nothing is consumed through a package manager, but it does mean the version number tells you nothing about coverage. If you pin a version in a study plan, that number refers to a site deployment of unknown age rather than to the set of problems available on the day you opened it. Judge freshness from the commit history of the specific problem directory instead, and expect a solution to appear in the tree well before any tag moves. The conventional commits enforced by commitlint give you a usable signal in the meantime, since the message for each added problem states what was added.
The site is a Cloudflare Worker, and previewing it also runs Python
The rendered site at leetcode.doocs.org is backed by two files at the repository root that place it on Cloudflare's edge runtime: wrangler.jsonc for configuration and worker.js for the worker entry point. A pnpm-workspace.yaml sits alongside pnpm-lock.yaml, and the manifest declares [email protected] as its package manager, so the tooling on that side is pnpm based.
The local preview route runs a Python script through the same bridge the formatters use:
node scripts/run-py.js scripts/preview.pySo the path from a pull request to a rendered page crosses Node, pnpm, and Python, even for a change that edits one problem's Markdown. The manifest also carries a prepare script that runs husky, which means a clone wires up the commit hooks on install, and those hooks are the five formatter routes from the first section. Contributors who only want to read can ignore all of it, since the Markdown is the product and the site renders it without a local build.
Editorial conclusion
doocs/leetcode earns a place in an interview prep rotation for anyone who learns by technique, since the index tells you which pattern a problem wants before you show the code. Skip it if you need difficulty tiers, a judge that runs your submission, or a license that treats source files unambiguously. Before relying on it, check the commit date for the problem you care about instead of the tag, and read the license yourself, because the Creative Commons choice is the one thing here that can constrain a company.
Frequently asked questions
What is LeetCode used for, according to doocs?
doocs collects solutions to LeetCode problems plus the Sword Finger Offer second edition, the Sword Finger Offer special training edition, and the sixth edition of the coding interview classic, implemented in Java, Python, C++, Go, TypeScript, Rust, and others. The index groups them by the technique that solves each problem, such as monotonic stack, multi-source BFS, string hashing, and backtracking with pruning.
Can a beginner start with LeetCode using the doocs solutions?
The repository has a top-level basic/ directory, and its topic sections move from binary search, prefix sums, and two pointers through monotonic stacks and deques up to A* search and memoized search, so there is a visible ramp from simple to harder patterns. No difficulty tiering of individual problems is given, and the problem titles in the index are written in Chinese.
Is LeetCode free or paid, and can I use the doocs solutions?
Nothing in this repository states what LeetCode itself charges, so that half cannot be answered from here. On its own terms, doocs/leetcode is licensed CC-BY-SA-4.0, requires attribution, and applies share-alike to derivative works, and the rendered site is at leetcode.doocs.org.
Is LeetCode very hard, and how does doocs handle the harder problems?
The index files hard problems by the mechanism that makes them tractable rather than by a difficulty label, so sliding puzzles, cutting trees for a golf event, and visiting all nodes in minimum steps all sit under A* search or bidirectional BFS, while backtracking problems are listed with pruning. The repository was last pushed on September 27, 2026, though the newest tag, v0.3.0, is dated February 20, 2025.
How do I use LeetCode for Python with the doocs repository?
Python is one of the listed solution languages, and every Python file passes through black with the string normalization skipped: the lint-staged route is `node scripts/run-py.js -m black -S`. Getting that hook working means installing the pinned Python dependencies first, which the setup:python npm script does from requirements.txt.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/doocs-leetcode)