olegshulyakov/doocs-leetcode-solutions
Doocs LeetCode Solutions LeetCode problems with solutions in many programming languages, built from the Doocs LeetCode repository. Each solution comes with the approach name, the reasoning that leads to it, and an explanation with complexity analysis. The dataset is meant for fine-tuning and evaluating code generation models. The dataset is regenerated monthly from the latest Doocs commit by the leetcode-dataset-generator tool. Structure The dataset has two… See the full description on the dataset page: https://huggingface.co/datasets/olegshulyakov/doocs-leetcode-solutions.
Doocs LeetCode Solutions
LeetCode problems with solutions in many programming languages, built from the Doocs LeetCode repository. Each solution comes with the approach name, the reasoning that leads to it, and an explanation with complexity analysis. The dataset is meant for fine-tuning and evaluating code generation models.
The dataset is regenerated monthly from the latest Doocs commit by the leetcode-dataset-generator tool.
Structure
The dataset has two configs:
default: one row per solution file (a problem in one language for one approach).problems: one row per problem; the solution fields below are nested in asolutionslist.
Data Fields
Languages: Bash, C, C#, C++, Cangjie, Dart, Go, Java, JavaScript, Kotlin, Nim, PHP, Python, Ruby, Rust, Scala, SQL, Swift, TypeScript.
Data Splits
Problems are assigned to a split by a hash of their id, so all solutions of a problem stay in the same split and existing problems keep their split as new ones are added.
How to Use
from datasets import load_dataset
dataset = load_dataset("olegshulyakov/doocs-leetcode-solutions", split="train")
# One row per problem with nested solutions:
# problems = load_dataset("olegshulyakov/doocs-leetcode-solutions", "problems", split="train")
sample = dataset[0]
print(f"Problem {sample['id']}: {sample['title']} ({sample['difficulty']})")
print(f"Approach {sample['approach']}: {sample['approach_name']}")
print(sample["thinking"])
print(sample["solution"])Limitations
- Solutions are community-written and may not be optimal.
- Descriptions are converted from HTML to Markdown. Superscripts and subscripts are written as
^xand_x(e.g.10^4), parenthesized when complex (e.g.2^(n-1)). - Alternative approaches (
approach> 1) often have onlythinkingand noexplanation. - Coverage is limited to problems that have solutions in the Doocs repository.
License and Attribution
This dataset is derived from doocs/leetcode by the Doocs community and is distributed under the same [CC-BY-SA-4.0](https://creativecommons.org/licenses/by-sa/4.0/) license. If you share or adapt it, you must give appropriate credit and distribute your contributions under the same license.
Problem statements are the property of LeetCode. This dataset is not affiliated with or endorsed by LeetCode or Doocs.
Contact
For questions or issues, please open an issue on GitHub.
