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labelled by Solution Pattern (Sample)
|
| 6 |
+
size_categories:
|
| 7 |
+
- n<1K
|
| 8 |
+
task_categories:
|
| 9 |
+
- text-classification
|
| 10 |
+
tags:
|
| 11 |
+
- code
|
| 12 |
+
- algorithms
|
| 13 |
+
- programming-problems
|
| 14 |
+
- technical-interviews
|
| 15 |
+
- leetcode
|
| 16 |
+
- taxonomy
|
| 17 |
+
configs:
|
| 18 |
+
- config_name: default
|
| 19 |
+
data_files:
|
| 20 |
+
- split: train
|
| 21 |
+
path: data/train.jsonl
|
| 22 |
---
|
| 23 |
+
|
| 24 |
+
# LeetCode Problems Labelled by Solution Pattern (Sample)
|
| 25 |
+
|
| 26 |
+
A 100-problem sample of LeetCode problems annotated with the **algorithmic technique that solves
|
| 27 |
+
them**, rather than the topic tag that describes what they are about.
|
| 28 |
+
|
| 29 |
+
LeetCode's own tags answer "what is this problem about" — `Array`, `String`, `Hash Table`. That is
|
| 30 |
+
not the same question as "how is it solved". Both *Two Sum* and *Longest Substring Without Repeating
|
| 31 |
+
Characters* are tagged `Hash Table`, but one is a complement lookup and the other is a sliding window
|
| 32 |
+
with a seen-set. This dataset adds a `solution_archetype` field that answers the second question.
|
| 33 |
+
|
| 34 |
+
The full corpus this sample is drawn from covers 3,000 problems across 29 archetypes.
|
| 35 |
+
|
| 36 |
+
## Dataset structure
|
| 37 |
+
|
| 38 |
+
One JSON object per line in `data/train.jsonl`:
|
| 39 |
+
|
| 40 |
+
| field | type | description |
|
| 41 |
+
| --- | --- | --- |
|
| 42 |
+
| `problem_number` | int | The problem's number on LeetCode |
|
| 43 |
+
| `title` | string | Problem title |
|
| 44 |
+
| `slug` | string | URL slug |
|
| 45 |
+
| `difficulty` | string | `Easy`, `Medium` or `Hard` |
|
| 46 |
+
| `topic_tags` | list[string] | LeetCode's own topic tags, unmodified |
|
| 47 |
+
| `solution_archetype` | string | **The annotation.** The technique that solves the problem |
|
| 48 |
+
| `has_reference_solution` | bool | Whether a worked reference solution exists for this problem |
|
| 49 |
+
| `leetcode_url` | string | Canonical problem URL on leetcode.com |
|
| 50 |
+
| `pattern_reference` | string \| null | Write-up of the archetype, where one exists |
|
| 51 |
+
|
| 52 |
+
### Sample row
|
| 53 |
+
|
| 54 |
+
```json
|
| 55 |
+
{
|
| 56 |
+
"problem_number": 1,
|
| 57 |
+
"title": "Two Sum",
|
| 58 |
+
"slug": "two-sum",
|
| 59 |
+
"difficulty": "Easy",
|
| 60 |
+
"topic_tags": ["Array", "Hash Table"],
|
| 61 |
+
"solution_archetype": "hash-map",
|
| 62 |
+
"has_reference_solution": true,
|
| 63 |
+
"leetcode_url": "https://leetcode.com/problems/two-sum/",
|
| 64 |
+
"pattern_reference": "https://www.stealthinterview.ai/leetcode/patterns/hash-map"
|
| 65 |
+
}
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
### Composition of this sample
|
| 69 |
+
|
| 70 |
+
100 problems, stratified to cover as many archetypes as possible while keeping the difficulty mix of
|
| 71 |
+
the source corpus: **21 Easy / 63 Medium / 16 Hard**, spanning **29 distinct archetypes**. Selection
|
| 72 |
+
is deterministic — problems are taken in ascending number, round-robin across archetypes — so the
|
| 73 |
+
sample is reproducible rather than a random draw. Premium-only problems are excluded, because their
|
| 74 |
+
statements are not publicly checkable.
|
| 75 |
+
|
| 76 |
+
## Usage
|
| 77 |
+
|
| 78 |
+
```python
|
| 79 |
+
from datasets import load_dataset
|
| 80 |
+
|
| 81 |
+
ds = load_dataset("<your-username>/leetcode-solution-patterns-sample", split="train")
|
| 82 |
+
|
| 83 |
+
# Problems solved by a monotonic stack
|
| 84 |
+
mono = ds.filter(lambda r: r["solution_archetype"] == "monotonic-stack")
|
| 85 |
+
|
| 86 |
+
# Where LeetCode's tag and the solving technique disagree
|
| 87 |
+
mismatch = ds.filter(
|
| 88 |
+
lambda r: "Hash Table" in r["topic_tags"] and r["solution_archetype"] != "hash-map"
|
| 89 |
+
)
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
## Provenance and what is actually original here
|
| 93 |
+
|
| 94 |
+
This distinction matters, so it is stated plainly:
|
| 95 |
+
|
| 96 |
+
- **Not original, and not owned by this dataset:** problem numbers, titles, slugs, difficulty ratings
|
| 97 |
+
and topic tags. These are factual references to problems hosted on LeetCode.
|
| 98 |
+
- **Original:** the `solution_archetype` labels and the taxonomy of 29 archetypes they are drawn
|
| 99 |
+
from. These were derived by analysing solution structure across the corpus and are the reason this
|
| 100 |
+
dataset exists.
|
| 101 |
+
|
| 102 |
+
**No problem statements, test cases, editorial content or LeetCode solutions are included in this
|
| 103 |
+
dataset.** Only metadata and links back to the canonical problem pages. If you need the problem text,
|
| 104 |
+
follow `leetcode_url`.
|
| 105 |
+
|
| 106 |
+
LeetCode is a trademark of its respective owner. This dataset is not affiliated with, endorsed by, or
|
| 107 |
+
sponsored by LeetCode.
|
| 108 |
+
|
| 109 |
+
## Licence
|
| 110 |
+
|
| 111 |
+
The **annotations** — `solution_archetype` and the taxonomy — are released under
|
| 112 |
+
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Attribution is appreciated if you use the
|
| 113 |
+
labels in research or a downstream dataset.
|
| 114 |
+
|
| 115 |
+
The referenced problem metadata is factual information about a third-party platform and is not
|
| 116 |
+
claimed under this licence.
|
| 117 |
+
|
| 118 |
+
## Limitations
|
| 119 |
+
|
| 120 |
+
- **One archetype per problem.** Many problems admit more than one valid approach; the label records
|
| 121 |
+
the technique the reference solution used, not the only one that works.
|
| 122 |
+
- **`bespoke` is a real category, not a fallback for hard problems.** It marks problems whose
|
| 123 |
+
solution does not generalise to a reusable pattern.
|
| 124 |
+
- **The taxonomy is opinionated.** Where you draw the line between `stack` and `monotonic-stack`, or
|
| 125 |
+
`dfs` and `graph-traversal`, is a judgement call. The boundaries here are consistent within the
|
| 126 |
+
corpus but are not a standard anyone else has ratified.
|
| 127 |
+
- **Sample, not corpus.** 100 of 3,000. Frequencies here will not match the full distribution.
|
| 128 |
+
|
| 129 |
+
## Source
|
| 130 |
+
|
| 131 |
+
Built from the problem library at
|
| 132 |
+
[stealthinterview.ai/leetcode](https://www.stealthinterview.ai/leetcode), which organises the full
|
| 133 |
+
3,000-problem set by solving technique. The archetype taxonomy and the per-technique write-ups —
|
| 134 |
+
including the template, complexity and applicable problems for each — are documented at
|
| 135 |
+
[stealthinterview.ai/leetcode/patterns](https://www.stealthinterview.ai/leetcode/patterns).
|
| 136 |
+
|
| 137 |
+
## Citation
|
| 138 |
+
|
| 139 |
+
```bibtex
|
| 140 |
+
@misc{leetcode_solution_patterns_2026,
|
| 141 |
+
title = {LeetCode Problems Labelled by Solution Pattern},
|
| 142 |
+
year = {2026},
|
| 143 |
+
url = {https://www.stealthinterview.ai/leetcode/patterns},
|
| 144 |
+
note = {Sample of 100 problems annotated with solving technique}
|
| 145 |
+
}
|
| 146 |
+
```
|