Team Ai
Datasetpublic

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.

sourceHugging Facecc-by-sa-4.0updated 4d agoView on Hugging Face
3likes387downloads
Dataset Card

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 a solutions list.

Data Fields

FieldTypeDescriptionExample
idint64Problem number1
titlestringProblem title"Two Sum"
slugstringProblem slug"two-sum"
urlstringProblem URL on leetcode.com"https://leetcode.com/problems/two-sum"
difficultystringDifficulty level"Easy", "Medium", "Hard"
ratingint64Contest rating; null when the problem has none1249
sourcestringContest source; may be empty"Weekly Contest 379 Q1"
descriptionstringProblem description as Markdown"Given an array of integers…"
tagslist<string>Problem tags["Array", "Hash Table"]
languagestringProgramming language of the solution"Python", "Java", "C++"
approachint64Approach number within the problem1, 2
approach_namestringApproach name; may be empty"Hash Table"
thinkingstringReasoning that leads to the approach; may be empty"Checking every pair is…"
explanationstringApproach explanation with complexity analysis; may be empty"We can use a hash table…"
solutionstringComplete solution code"class Solution:\n def…"

Languages: Bash, C, C#, C++, Cangjie, Dart, Go, Java, JavaScript, Kotlin, Nim, PHP, Python, Ruby, Rust, Scala, SQL, Swift, TypeScript.

Data Splits

SplitShare of problems
train~95%
test~5%

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

python
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 ^x and _x (e.g. 10^4), parenthesized when complex (e.g. 2^(n-1)).
  • —Alternative approaches (approach > 1) often have only thinking and no explanation.
  • —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.