CoolFace
Datasetpublic

AmareshHebbar/leetcode-codegen-python

LeetCode Code-Gen Dataset — Python 2522 rows. Given a problem statement, its input/output examples, and a required algorithm/technique, generate a correct Python solution. Part of a 4-language collection built from the same source: see the sibling Python, Java, C++, and JavaScript datasets. Verification Every row was extracted, then executed in a sandboxed subprocess against the problem's own stated examples. Only rows that passed all examples are included -- this… See the full description on the dataset page: https://huggingface.co/datasets/AmareshHebbar/leetcode-codegen-python.

sourceHugging Facemitupdated 3mo agoView on Hugging Face
1likes93downloads
Dataset Card

LeetCode Code-Gen Dataset — Python

2522 rows. Given a problem statement, its input/output examples, and a required algorithm/technique, generate a correct Python solution.

Part of a 4-language collection built from the same source: see the sibling Python, Java, C++, and JavaScript datasets.

Verification

Every row was extracted, then executed in a sandboxed subprocess against the problem's own stated examples. Only rows that passed all examples are included -- this is not just scraped code, it's checked code.

Source

Extracted from doocs/leetcode, which documents multiple named solution approaches per problem (e.g. "Dynamic Programming", "Two Pointers", "Divide and Conquer") -- this is what makes per-row algorithm labeling possible, since the same problem can appear multiple times with a different technique and different code each time.

Fields

fielddescription
slugLeetCode problem slug
solution_idunique id: problem + approach index + language
primary_algorithmnormalized algorithm/technique label
verifiedtrue/false for Python (execution-checked), null for other languages
messageschat-format (system/user/assistant), ready for SFT

Example row

json
{
  "slug": "house-robber",
  "primary_algorithm": "Dynamic Programming",
  "messages": [
    {"role": "system", "content": "You are a competitive programming assistant..."},
    {"role": "user", "content": "### Problem\n...\n### Algorithm\nDynamic Programming"},
    {"role": "assistant", "content": "```python\n...\n```"}
  ]
}

Known gaps

  • SQL/database problems excluded (wrong problem type for a code-execution harness)
  • Design/class problems (LRU Cache, iterators) excluded -- they need a sequence of method calls to test, not a single input -> output check
  • Some Brute Force labels are a fallback where the source didn't name a specific technique for that approach