LeetCodeDataset: A Temporal Dataset for Robust Evaluation and Efficient Training of Code LLMs

Yunhui Xia, Wei Shen, Yan Wang, Jason Klein Liu, Huifeng Sun, Siyue Wu, Jian Hu, Xiaolong XuarXiv 2025 · DOI

Introduction

Evaluating Large Language Models (LLMs) on coding tasks has become increasingly difficult due to data contamination. As models are trained on massive internet crawls, they often encounter the solutions to popular benchmarks like HumanEval or older LeetCode problems during pre-training. This makes it nearly impossible to distinguish between genuine logical reasoning and simple memorization.

To address this, the LeetCodeDataset introduces a high-quality, reasoning-focused benchmark utilizing a strict temporal split. By focusing on problems released after July 2024 and implementing rigorous testing standards, this dataset provides a clean environment for both evaluating and training the next generation of code LLMs.

Methodology

The construction of the LeetCodeDataset followed a multi-stage pipeline designed for maximum data integrity:

  1. Metadata Acquisition: Using LeetCode’s GraphQL API, the authors collected 3,115 Python problems, capturing descriptions, starter code, and algorithmic topic tags.
  2. Canonical Verification: Reference solutions were sourced from GitHub and verified directly on the LeetCode platform to ensure 100% functional correctness.
  3. LLM-Driven Test Case Generation: To minimize "false positives" (where buggy code passes simple tests), LLMs were prompted to generate an average of 100+ complex test cases per problem, focusing specifically on edge cases.
  4. Sandboxed Execution: A secure environment was used to run solutions against these new test cases to generate ground-truth outputs.
  5. Temporal Splitting: Problems released after July 1, 2024, were designated as the test set, while earlier problems formed the training set, ensuring the evaluation data remained "unseen" by existing models.

Dataset Characteristics

The final dataset consists of 2,869 curated Python problems. One of its strengths is the inclusion of detailed metadata, such as topic tags, which allows for granular analysis of model performance across different algorithmic domains.

Distribution of topic tags across the LeetCodeDataset, highlighting the prevalence of complex algorithmic categories like Arrays, Strings, and Dynamic Programming.

Key Insights and Results

The Impact of Temporal Evaluation

By tracking performance over time, the researchers confirmed that contamination is a significant factor in current benchmark scores. Models generally perform better on problems released before their training cutoff dates. The LeetCodeDataset's temporal split provides a more accurate reflection of a model's zero-shot reasoning capabilities.

Temporal performance (Pass@1) of leading LLMs on problems released between July 2024 and February 2025, illustrating the impact of the temporal split on evaluation.

Quality Over Quantity in Training

A major finding of this research is that training efficiency is driven by data quality rather than volume. A model fine-tuned on just 2.6K high-quality, reasoning-rich samples from the LeetCodeDataset achieved a 79.9% pass rate on HumanEval. This performance matches or exceeds models trained on datasets 40 times larger (e.g., Magicoder with 110K samples). This suggests that model-generated solutions—which often include step-by-step reasoning and comments—are more effective for training than terse human-written code.

The Reasoning Gap

Reasoning-heavy models, such as DeepSeek-R1 and QwQ-Plus, significantly outperformed traditional LLMs. DeepSeek-R1 led the evaluation with a 65.23% overall pass rate. Among non-reasoning models, Claude 3.7 Sonnet performed best at 50.78%, while GPT-4o and DeepSeek-V3 both reached 35.55%. The performance gap was most evident in complex domains like Dynamic Programming, where logical deduction is required over pattern matching.

Limitations and Future Work

While the LeetCodeDataset provides a more robust evaluation framework, some challenges remain. Even with 100+ test cases, there is a residual risk of false positives if input patterns are not sufficiently diverse. Additionally, the current dataset focuses on functional correctness rather than time or space complexity. Future iterations aim to expand the dataset to multiple programming languages and incorporate more rigorous complexity-based metrics to further challenge state-of-the-art models.

Summary updated

BibTeX
@misc{xia2025leetcodedataset,
  author = {Yunhui Xia and Wei Shen and Yan Wang and Jason Klein Liu and Huifeng Sun and Siyue Wu and Jian Hu and Xiaolong Xu},
  title = {{LeetCodeDataset: A Temporal Dataset for Robust Evaluation and Efficient Training of Code LLMs}},
  year = {2025},
  eprint = {2504.14655},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.14655},
}
Figure