slug_name stringlengths 3 58 | meta_info dict | id stringlengths 1 3 | difficulty stringclasses 3
values | pretty_content listlengths 1 1 | solutions listlengths 3 36 | prompt stringlengths 120 527 | generator_code stringlengths 72 1.58k | convert_online stringclasses 16
values | convert_offline stringclasses 13
values | evaluate_offline stringclasses 11
values | entry_point stringlengths 3 31 | test_cases stringlengths 1.56k 32.9M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
spiral-matrix | {
"data": {
"question": {
"categoryTitle": "Algorithms",
"content": "<p>Given an <code>m x n</code> <code>matrix</code>, return <em>all elements of the</em> <code>matrix</code> <em>in spiral order</em>.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n<img alt=\"\" src=\"htt... | 54 | Medium | [
"Given an m x n matrix, return all elements of the matrix in spiral order.\n\n \nExample 1:\n\nInput: matrix = [[1,2,3],[4,5,6],[7,8,9]]\nOutput: [1,2,3,6,9,8,7,4,5]\n\n\nExample 2:\n\nInput: matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]\nOutput: [1,2,3,4,8,12,11,10,9,5,6,7]\n\n\n \nConstraints:\n\n\n\tm == matrix.le... | [
{
"hash": -7901417908281767000,
"runtime": "44ms",
"solution": "class Solution:\n def spiralOrder(self, matrix: List[List[int]]) -> List[int]:\n \n top = left = 0\n bottom = len(matrix)-1\n right = len(matrix[0])-1\n ans = []\n while left<=right and top<=bott... | class Solution(object):
def spiralOrder(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: List[int]
"""
| import random
def generate_test_case():
m = random.randint(1, 10)
n = random.randint(1, 10)
return [[random.randint(-100, 100) for _ in range(n)] for _ in range(m)] | def convert_online(case):
return case | def convert_offline(case):
return case | def evaluate_offline(inputs, outputs, expected):
if outputs == expected:
return True
return False | spiralOrder | [{"input": [[[1, 2, 3], [4, 5, 6], [7, 8, 9]]], "expected": [1, 2, 3, 6, 9, 8, 7, 4, 5]}, {"input": [[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]], "expected": [1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7]}, {"input": [[[-88, -52, 62, -29, -4, 20, 59, -57], [76, 56, -93, 38, 85, -15, -96, 48], [-4, -30, 63, -87, -94, -35, -... |
summary-ranges | {
"data": {
"question": {
"categoryTitle": "Algorithms",
"content": "<p>You are given a <strong>sorted unique</strong> integer array <code>nums</code>.</p>\n\n<p>A <strong>range</strong> <code>[a,b]</code> is the set of all integers from <code>a</code> to <code>b</code> (inclusive).</p>\n\n<p>Return <... | 228 | Easy | [
"You are given a sorted unique integer array nums.\n\nA range [a,b] is the set of all integers from a to b (inclusive).\n\nReturn the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, each element of nums is covered by exactly one of the ranges, and there is no integer x such ... | [
{
"hash": -7164636124794358000,
"runtime": "25ms",
"solution": "class Solution:\n def summaryRanges(self, nums: List[int]) -> List[str]:\n result = []\n for num in nums:\n if not result or num > result[-1][-1] + 1:\n result.append([num, num])\n else:... | class Solution(object):
def summaryRanges(self, nums):
"""
:type nums: List[int]
:rtype: List[str]
"""
| import random
def generate_test_case():
length = random.randint(0, 20)
nums = sorted(random.sample(range(-2**31, 2**31 - 1), length))
return nums | def convert_online(case):
return case | def convert_offline(case):
return case | def evaluate_offline(inputs, outputs, expected):
if outputs == expected:
return True
return False | summaryRanges | [{"input": [[0, 1, 2, 4, 5, 7]], "expected": ["0->2", "4->5", "7"]}, {"input": [[0, 2, 3, 4, 6, 8, 9]], "expected": ["0", "2->4", "6", "8->9"]}, {"input": [[588674346, 1857543781, 2003596430]], "expected": ["588674346", "1857543781", "2003596430"]}, {"input": [[-2121171139, 341570958, 344432966, 1014930966, 1218511757,... |
distinct-subsequences | {
"data": {
"question": {
"categoryTitle": "Algorithms",
"content": "<p>Given two strings s and t, return <i>the number of distinct</i> <b><i>subsequences</i></b><i> of </i>s<i> which equals </i>t.</p>\n\n<p>The test cases are generated so that the answer fits on a 32-bit signed integer.</p>\n\n<p>&nb... | 115 | Hard | [
"Given two strings s and t, return the number of distinct subsequences of s which equals t.\n\nThe test cases are generated so that the answer fits on a 32-bit signed integer.\n\n \nExample 1:\n\nInput: s = \"rabbbit\", t = \"rabbit\"\nOutput: 3\nExplanation:\nAs shown below, there are 3 ways you can generate \"rab... | [
{
"hash": 1869391220693607700,
"runtime": "36ms",
"solution": "class Solution:\n def numDistinct(self, s: str, t: str) -> int:\n @lru_cache(None)\n def dp(i,j):\n if i<j: return 0\n if j<0: return 1\n res = dp(i-1,j)\n if s[i]==t[j]: res += dp... | class Solution(object):
def numDistinct(self, s, t):
"""
:type s: str
:type t: str
:rtype: int
"""
| import random
import string
def generate_test_case():
len_s = random.randint(1, 1000)
len_t = random.randint(1, len_s)
s = ''.join(random.choices(string.ascii_lowercase, k = len_s))
t = ''.join(random.choices(s, k = len_t))
return s, t | def convert_online(case):
return case | def convert_offline(case):
return case | def evaluate_offline(inputs, outputs, expected):
if outputs == expected:
return True
return False | numDistinct | [{"input": ["rabbbit", "rabbit"], "expected": 3}, {"input": ["babgbag", "bag"], "expected": 5}, {"input": ["rinnqntsvlekptulnzngbjkkaulvqututxrjaoshcnxwkndhglwlraazkcagureurlzfdmhcmmhccixaupkuiblgzfhjxjdgdcewrozlxyttvjfpvxrfrnbarmdwkkwhltzslmtgscbdjmrnuiwbvupwvujvoakzqnqhwctjqzhcjtftcsjqwmhujbbuueyjoxfosyxqahcpntfatrlm... |
first-missing-positive | {"data":{"question":{"categoryTitle":"Algorithms","content":"<p>Given an unsorted integer array <cod(...TRUNCATED) | 41 | Hard | ["Given an unsorted integer array nums, return the smallest missing positive integer.\n\nYou must im(...TRUNCATED) | [{"hash":5196614306897904948,"runtime":"511ms","solution":"class Solution:\n def firstMissingPosi(...TRUNCATED) | "class Solution(object):\n def firstMissingPositive(self, nums):\n \"\"\"\n :type n(...TRUNCATED) | "import random\nimport math\n\ndef generate_test_case():\n n = random.randint(1, 10**5)\n nums(...TRUNCATED) | def convert_online(case):
return case | def convert_offline(case):
return case | "def evaluate_offline(inputs, outputs, expected):\n if outputs == expected:\n return True\(...TRUNCATED) | firstMissingPositive | "[{\"input\": [[1, 2, 0]], \"expected\": 3}, {\"input\": [[3, 4, -1, 1]], \"expected\": 2}, {\"input(...TRUNCATED) |
permutation-sequence | {"data":{"question":{"categoryTitle":"Algorithms","content":"<p>The set <code>[1, 2, 3, ..., n](...TRUNCATED) | 60 | Hard | ["The set [1, 2, 3, ..., n] contains a total of n! unique permutations.\n\nBy listing and labeling (...TRUNCATED) | [{"hash":-2445517919244890175,"runtime":"4463ms","solution":"class Solution:\n def nextPermutatio(...TRUNCATED) | "class Solution(object):\n def getPermutation(self, n, k):\n \"\"\"\n :type n: int\(...TRUNCATED) | "import random\nimport math\n\ndef generate_test_case():\n n = random.randint(1,9)\n k = rando(...TRUNCATED) | def convert_online(case):
return case | def convert_offline(case):
return case | "def evaluate_offline(inputs, outputs, expected):\n if outputs == expected:\n return True\(...TRUNCATED) | getPermutation | "[{\"input\": [3, 3], \"expected\": \"213\"}, {\"input\": [4, 9], \"expected\": \"2314\"}, {\"input\(...TRUNCATED) |
two-sum-ii-input-array-is-sorted | {"data":{"question":{"categoryTitle":"Algorithms","content":"<p>Given a <strong>1-indexed</strong> a(...TRUNCATED) | 167 | Medium | ["Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find t(...TRUNCATED) | [{"hash":792140305618905326,"runtime":"234ms","solution":"class Solution:\n def twoSum(self, nums(...TRUNCATED) | "class Solution(object):\n def twoSum(self, numbers, target):\n \"\"\"\n :type numb(...TRUNCATED) | "import random\n\ndef generate_test_case():\n # Generate the length of the array based on the con(...TRUNCATED) | def convert_online(case):
return case | def convert_offline(case):
return case | "def evaluate_offline(inputs, outputs, expected):\n if outputs == expected:\n return True\(...TRUNCATED) | twoSum | "[{\"input\": [[2, 7, 11, 15], 9], \"expected\": [1, 2]}, {\"input\": [[2, 3, 4], 6], \"expected\": (...TRUNCATED) |
expression-add-operators | {"data":{"question":{"categoryTitle":"Algorithms","content":"<p>Given a string <code>num</code> that(...TRUNCATED) | 282 | Hard | ["Given a string num that contains only digits and an integer target, return all possibilities to in(...TRUNCATED) | [{"hash":-1923361310744562821,"runtime":"5482ms","solution":"class Solution:\n def addOperators(s(...TRUNCATED) | "class Solution(object):\n def addOperators(self, num, target):\n \"\"\"\n :type nu(...TRUNCATED) | "import random\nimport string\n\ndef generate_test_case():\n num = ''.join(random.choice(string.d(...TRUNCATED) | def convert_online(case):
return case | def convert_offline(case):
return case | "def evaluate_offline(inputs, outputs, expected):\n if sorted(outputs) == sorted(expected):\n (...TRUNCATED) | addOperators | "[{\"input\": [\"123\", 6], \"expected\": [\"1*2*3\", \"1+2+3\"]}, {\"input\": [\"232\", 8], \"expec(...TRUNCATED) |
sum-root-to-leaf-numbers | {"data":{"question":{"categoryTitle":"Algorithms","content":"<p>You are given the <code>root</code> (...TRUNCATED) | 129 | Medium | ["You are given the root of a binary tree containing digits from 0 to 9 only.\n\nEach root-to-leaf p(...TRUNCATED) | [{"hash":4060210370930641564,"runtime":"39ms","solution":"# Definition for a binary tree node.\n# cl(...TRUNCATED) | "# Definition for a binary tree node.\n# class TreeNode(object):\n# def __init__(self, val=0, le(...TRUNCATED) | "import random\nclass TreeNode:\n def __init__(self, x):\n self.val = x\n self.left(...TRUNCATED) | def convert_online(case):
return case | "def convert_offline(case):\n import lctk\n inputs, expected = case\n inputs = lctk.binaryT(...TRUNCATED) | "def evaluate_offline(inputs, outputs, expected):\n if outputs == expected:\n return True\(...TRUNCATED) | sumNumbers | "[{\"input\": [[1, 2, 3]], \"expected\": 25}, {\"input\": [[4, 9, 0, 5, 1]], \"expected\": 1026}, {\(...TRUNCATED) |
license-key-formatting | {"data":{"question":{"categoryTitle":"Algorithms","content":"<p>You are given a license key represen(...TRUNCATED) | 482 | Easy | ["You are given a license key represented as a string s that consists of only alphanumeric character(...TRUNCATED) | [{"hash":-3618123255579938907,"runtime":"150ms","solution":"class Solution:\n def licenseKeyForma(...TRUNCATED) | "class Solution(object):\n def licenseKeyFormatting(self, s, k):\n \"\"\"\n :type s(...TRUNCATED) | "import random\nimport string\n\ndef generate_test_case():\n length = random.randint(1, 10**3)\n (...TRUNCATED) | def convert_online(case):
return case | def convert_offline(case):
return case | "def evaluate_offline(inputs, outputs, expected):\n if outputs == expected:\n return True\(...TRUNCATED) | licenseKeyFormatting | "[{\"input\": [\"5F3Z-2e-9-w\", 4], \"expected\": \"5F3Z-2E9W\"}, {\"input\": [\"2-5g-3-J\", 2], \"e(...TRUNCATED) |
gas-station | {"data":{"question":{"categoryTitle":"Algorithms","content":"<p>There are <code>n</code> gas station(...TRUNCATED) | 134 | Medium | ["There are n gas stations along a circular route, where the amount of gas at the ith station is gas(...TRUNCATED) | [{"hash":-964204136414872315,"runtime":"1334ms","solution":"class Solution:\n def canCompleteCirc(...TRUNCATED) | "class Solution(object):\n def canCompleteCircuit(self, gas, cost):\n \"\"\"\n :typ(...TRUNCATED) | "import random\n\ndef generate_test_case():\n n = random.randint(1, 10**5)\n gas = [random.ran(...TRUNCATED) | def convert_online(case):
return case | def convert_offline(case):
return case | "def evaluate_offline(inputs, outputs, expected):\n if outputs == expected:\n return True\(...TRUNCATED) | canCompleteCircuit | "[{\"input\": [[1, 2, 3, 4, 5], [3, 4, 5, 1, 2]], \"expected\": 3}, {\"input\": [[2, 3, 4], [3, 4, 3(...TRUNCATED) |
End of preview. Expand in Data Studio
NewMercury
This dataset is a part of an efficiency evaluation framework for LLM-generated code. It is based on Mercury, a competitive programming benchmark, with the following improvements:
- test generation facilities and extended test suites
- corrected test generation, input conversion and solution evaluation functions
- enhanced sandbox with additional library imports and adjusted time/recursion limits
See this repository on Github for more details.
- Downloads last month
- 27