Datasets:
File size: 2,531 Bytes
79e5554 43134c9 fae5c7d 43134c9 fae5c7d 79e5554 43134c9 fae5c7d 43134c9 fae5c7d 43134c9 fae5c7d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | ---
license: mit
task_categories:
- text-generation
language:
- en
pretty_name: LeetCode Code-Gen (Python)
size_categories:
- 1K<n<10K
tags:
- code
- python
- leetcode
- algorithms
- code-generation
- competitive-programming
- instruction-tuning
- sft
---
# 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](https://huggingface.co/datasets/AmareshHebbar/leetcode-codegen-python),
[Java](https://huggingface.co/datasets/AmareshHebbar/leetcode-codegen-java),
[C++](https://huggingface.co/datasets/AmareshHebbar/leetcode-codegen-cpp), and
[JavaScript](https://huggingface.co/datasets/AmareshHebbar/leetcode-codegen-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](https://github.com/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
| field | description |
|---|---|
| `slug` | LeetCode problem slug |
| `solution_id` | unique id: problem + approach index + language |
| `primary_algorithm` | normalized algorithm/technique label |
| `verified` | `true`/`false` for Python (execution-checked), `null` for other languages |
| `messages` | chat-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
|