leetcode / README.md
oleksa12345's picture
Update README.md
f3b2dce verified
|
Raw History Blame Contribute Delete
5.73 kB
---
license: cc-by-4.0
language:
- en
pretty_name: LeetCode Problems Labelled by Solution Pattern (Sample)
size_categories:
- n<1K
task_categories:
- text-classification
tags:
- code
- algorithms
- programming-problems
- technical-interviews
- leetcode
- taxonomy
configs:
- config_name: default
data_files:
- split: train
path: data/train.jsonl
---
# LeetCode Problems Labelled by Solution Pattern (Sample)
A 100-problem sample of LeetCode problems annotated with the **algorithmic technique that solves
them**, rather than the topic tag that describes what they are about.
LeetCode's own tags answer "what is this problem about" — `Array`, `String`, `Hash Table`. That is
not the same question as "how is it solved". Both *Two Sum* and *Longest Substring Without Repeating
Characters* are tagged `Hash Table`, but one is a complement lookup and the other is a sliding window
with a seen-set. This dataset adds a `solution_archetype` field that answers the second question.
The full corpus this sample is drawn from covers 3,000 problems across 29 archetypes.
## Dataset structure
One JSON object per line in `data/train.jsonl`:
| field | type | description |
| --- | --- | --- |
| `problem_number` | int | The problem's number on LeetCode |
| `title` | string | Problem title |
| `slug` | string | URL slug |
| `difficulty` | string | `Easy`, `Medium` or `Hard` |
| `topic_tags` | list[string] | LeetCode's own topic tags, unmodified |
| `solution_archetype` | string | **The annotation.** The technique that solves the problem |
| `has_reference_solution` | bool | Whether a worked reference solution exists for this problem |
| `leetcode_url` | string | Canonical problem URL on leetcode.com |
| `pattern_reference` | string \| null | Write-up of the archetype, where one exists |
### Sample row
```json
{
"problem_number": 1,
"title": "Two Sum",
"slug": "two-sum",
"difficulty": "Easy",
"topic_tags": ["Array", "Hash Table"],
"solution_archetype": "hash-map",
"has_reference_solution": true,
"leetcode_url": "https://leetcode.com/problems/two-sum/",
"pattern_reference": "https://www.stealthinterview.ai/leetcode/patterns/hash-map"
}
```
### Composition of this sample
100 problems, stratified to cover as many archetypes as possible while keeping the difficulty mix of
the source corpus: **21 Easy / 63 Medium / 16 Hard**, spanning **29 distinct archetypes**. Selection
is deterministic — problems are taken in ascending number, round-robin across archetypes — so the
sample is reproducible rather than a random draw. Premium-only problems are excluded, because their
statements are not publicly checkable.
## Usage
```python
from datasets import load_dataset
ds = load_dataset("<your-username>/leetcode-solution-patterns-sample", split="train")
# Problems solved by a monotonic stack
mono = ds.filter(lambda r: r["solution_archetype"] == "monotonic-stack")
# Where LeetCode's tag and the solving technique disagree
mismatch = ds.filter(
lambda r: "Hash Table" in r["topic_tags"] and r["solution_archetype"] != "hash-map"
)
```
## Provenance and what is actually original here
This distinction matters, so it is stated plainly:
- **Not original, and not owned by this dataset:** problem numbers, titles, slugs, difficulty ratings
and topic tags. These are factual references to problems hosted on LeetCode.
- **Original:** the `solution_archetype` labels and the taxonomy of 29 archetypes they are drawn
from. These were derived by analysing solution structure across the corpus and are the reason this
dataset exists.
**No problem statements, test cases, editorial content or LeetCode solutions are included in this
dataset.** Only metadata and links back to the canonical problem pages. If you need the problem text,
follow `leetcode_url`.
LeetCode is a trademark of its respective owner. This dataset is not affiliated with, endorsed by, or
sponsored by LeetCode.
## Licence
The **annotations** — `solution_archetype` and the taxonomy — are released under
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Attribution is appreciated if you use the
labels in research or a downstream dataset.
The referenced problem metadata is factual information about a third-party platform and is not
claimed under this licence.
## Limitations
- **One archetype per problem.** Many problems admit more than one valid approach; the label records
the technique the reference solution used, not the only one that works.
- **`bespoke` is a real category, not a fallback for hard problems.** It marks problems whose
solution does not generalise to a reusable pattern.
- **The taxonomy is opinionated.** Where you draw the line between `stack` and `monotonic-stack`, or
`dfs` and `graph-traversal`, is a judgement call. The boundaries here are consistent within the
corpus but are not a standard anyone else has ratified.
- **Sample, not corpus.** 100 of 3,000. Frequencies here will not match the full distribution.
## Source
Built from the problem library at
[stealthinterview.ai/leetcode](https://www.stealthinterview.ai/leetcode), which organises the full
3,000-problem set by solving technique. The archetype taxonomy and the per-technique write-ups —
including the template, complexity and applicable problems for each — are documented at
[stealthinterview.ai/leetcode/patterns](https://www.stealthinterview.ai/leetcode/patterns).
## Citation
```bibtex
@misc{leetcode_solution_patterns_2026,
title = {LeetCode Problems Labelled by Solution Pattern},
year = {2026},
url = {https://www.stealthinterview.ai/leetcode/patterns},
note = {Sample of 100 problems annotated with solving technique}
}
```