TL;DR
This paper presents a rigorous performance audit of 18 Large Language Models (LLMs) tasked with solving over 2,000 Leetcode problems. Beyond just checking if the code works, the researchers benchmarked the runtime and memory efficiency of AI-generated solutions against human-written code, finding that top-tier models like OpenAI's o1-mini already outperform 63% of human submissions in execution speed.
What Problem Does This Paper Address?
While we know LLMs are becoming proficient at writing code, most evaluations focus solely on "functional correctness"—does the code pass the test cases? In the real world of software engineering, efficiency is just as vital as correctness. An algorithm that works but runs in $O(n^2)$ time when an $O(n \log n)$ solution exists is often unacceptable for scalable systems.
This paper addresses the lack of comprehensive data on the computational efficiency of LLM-generated code. By using Leetcode as a benchmark, the authors can compare AI performance directly against a massive global dataset of human attempts, providing a clearer picture of where AI stands in the hierarchy of algorithmic problem-solving.
Methods
The researchers developed a systematic pipeline for evaluation:
- Data Collection: They crawled Leetcode to collect 2,014 problems across Easy, Medium, and Hard difficulties.
- Code Generation: They used a Python framework to prompt 18 different models (including the GPT-4 family, CodeLlama, and WizardCoder) using five different temperature settings (0.2 to 1.0) to account for randomness and creativity.
- Evaluation Metrics:
- Functional Correctness: Measured via the standard
pass@kmetric (the probability that at least one of $k$ generated samples is correct).
- Functional Correctness: Measured via the standard
- Efficiency Benchmarking: They used
pytest-benchmarkfor local runtime analysis and, crucially, utilized Leetcode’s Runtime Percentile Rank. This rank tells you what percentage of human submissions the AI's code outperformed. - Resource Usage: They tracked memory consumption to identify models that produce "bloated" solutions.
Datasets
The primary dataset consists of 2,104 Leetcode problems. The authors maintained a difficulty distribution of approximately 11:50:10 (Easy:Medium:Hard), reflecting the platform's natural spread. All solutions were generated in Python, chosen for its ubiquity in technical interviews and competitive programming.
Key Insights and Ideas
- The "GPT-4 Gap": There is a massive performance chasm between top-tier proprietary models and the rest of the field. As seen in the results table, the GPT-4 family operates in a different league compared to mid-tier models like CodeLlama or specialized models like StarCoder.
- AI vs. Human Efficiency: One of the most striking findings is that LLM-generated code isn't just "good enough" to pass; it's often highly optimized. The o1-mini model achieved a mean runtime percentile of 63%, meaning it is faster than the majority of human-written solutions for the same problems.
- Temperature Sensitivity: The researchers observed that temperature settings significantly impact not just the variety of solutions, but their efficiency. Finding the optimal temperature is key to extracting high-performance code from these models.
- Leetcode as a Research Proxy: The paper validates Leetcode as a robust dataset for evaluating not just logic, but the "engineering quality" of AI code, thanks to its built-in competitive ranking system.
Key Results
The quantitative results highlight a clear hierarchy in the LLM landscape:
- Top Performers: GPT-4o led the pack with a 43.36% pass@1 rate, followed closely by other GPT-4 variants.
- Efficiency: The runtime analysis for o1-mini shows a distribution skewed toward the higher percentiles, indicating that when the model solves a problem, it tends to do so efficiently.

- The Long Tail: Most open-source and smaller models (e.g., InCoder, CodeGen) struggled significantly, often staying below a 5% pass@1 rate on this diverse dataset.
The runtime and memory scatter plots (Figures 2 and 1 in the paper) reveal that while most models stay within reasonable resource bounds, there are occasional outliers where models produce significantly slower or more memory-intensive code.

Limitations and Future Work
The authors acknowledge several key limitations:
- Language Constraint: The study was limited to Python. Performance might vary significantly in lower-level languages like C++ or Java where manual memory management is required.
- Data Leakage: Since Leetcode is a public platform, there is a high probability that many of these problems were included in the training sets of the evaluated LLMs. This "memorization" could inflate performance scores.
- Problem Complexity: While Leetcode covers algorithmic logic well, it doesn't necessarily reflect real-world software engineering challenges like system design, maintainability, or integrating with large legacy codebases.
Future work could involve testing on "hidden" or new problems to mitigate data leakage and expanding the evaluation to include multi-file project generation and system-level performance.
Summary updated