File size: 4,059 Bytes
0b39512
 
a086482
 
8e3f15c
 
 
 
 
 
 
0b39512
 
 
 
 
 
6be3e1d
0b39512
6be3e1d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b39512
6be3e1d
0b39512
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4d4e7c4
0b39512
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
---
license: cc-by-sa-4.0
task_categories:
- text-generation
language:
- en
tags:
- code
pretty_name: Doocs LeetCode Solutions
size_categories:
- 10K<n<100K
---

# Doocs LeetCode Solutions

A comprehensive dataset of LeetCode problems and solutions created from the [Doocs LeetCode](https://github.com/doocs/leetcode) repository. This dataset is designed for fine-tuning large language models to understand programming problems and generate code solutions.

## Description

- Repository: [Doocs LeetCode Solutions](https://github.com/doocs/leetcode)
- Total Problems: 3500+
- Total Solutions: 15,000+ (across multiple languages)
- Size: ~60 MB (Parquet format)
- Languages:
   - C
   - Cangjie
   - C++
   - C#
   - Dart
   - Go
   - Java
   - JavaScript
   - Kotlin
   - Nim
   - PHP
   - Python
   - Ruby
   - Rust
   - Scala
   - Bash
   - SQL
   - Swift
   - TypeScript

## Structure

### Data Fields

| Field         | Type       | Description                                | Example                          |
|---------------|------------|--------------------------------------------|----------------------------------|
| `id`          | `string`   | Problem ID                                 | "0001"                           |
| `title`       | `string`   | Problem title (slugified)                  | "two-sum"                        |
| `difficulty`  | `string`   | Problem difficulty level                   | "Easy", "Medium", "Hard"         |
| `description` | `string`   | Problem description in Markdown            | "Given an array of integers..."  |
| `tags`        | `string`   | Problem category tags                      | "Array; Hash Table"              |
| `language`    | `string`   | Programming language of solution           | "Python", "Java", "C++"          |
| `solution`    | `string`   | Complete solution code                     | "class Solution:\n    def..."    |

### Data Splits

The dataset contains a single comprehensive split containing all problems and solutions:

| Split   | Problems | Solutions |
|---------|----------|-----------|
| `train` | 3500+    | 15,000+   |

## How to Use

### Using Hugging Face `datasets` Library

```python
from datasets import load_dataset

# Load the dataset
dataset = load_dataset("olegshulyakov/doocs-leetcode-solutions")

# Access a sample
sample = dataset['train'][0]
print(f"Problem {sample['id']}: {sample['title']}")
print(f"Difficulty: {sample['difficulty']}")
print(f"Tags: {sample['tags']}")
print(f"Language: {sample['language']}")
print(f"Solution:\n{sample['solution']}")
```

## Dataset Creation

### Source Data
- Collected from [Doocs LeetCode](https://github.com/doocs/leetcode) repository
- Solutions cover 14+ programming languages
- Includes problems from LeetCode's entire problem set

### Preprocessing
1. Repository cloned and processed using our [dataset generator tool](https://github.com/olegshulyakov/leetcode-dataset-generator).
2. Metadata extracted from README_EN.md files.
3. Solution files parsed and mapped to programming languages.
4. Special characters and encoding issues resolved.

## Intended Use

### Primary Use
- Fine-tuning code generation models
- Training programming problem-solving AI
- Educational purposes for learning algorithms

### Possible Uses
- Benchmarking code generation models
- Studying programming patterns across languages
- Analyzing problem difficulty characteristics
- Creating programming tutorials and examples

### Limitations
- Solutions may not be optimal (community solutions)
- Some edge cases might not be covered
- Problem descriptions may contain markdown/html formatting
- Limited to problems available in the Doocs repository

## License
This dataset is licensed under the **CC-BY-SA-4.0 License** - see [LICENSE](LICENSE) file for details.

## Copyright
The copyright of this project belongs to [Doocs](https://github.com/doocs) community.

## Contact
For questions or issues regarding the dataset, please open an issue on [GitHub](https://github.com/olegshulyakov/leetcode-dataset-generator/issues).