metadata
license: mit
task_categories:
- text-generation
language:
- en
tags:
- code
LeetCode-Contest
Contains 80 questions of LeetCode weekly and bi-weekly contests released after March 2024.
Each question contains an average of 644 test cases, as well as programming solutions in Python language collected from the official LeetCode website.
Dataset Structure
Dataset Fields
- index: The problem numbers in the dataset, from 0 to 79.
- title: The title of the problem.
- title_slug: The title name connected by "_".
- question_id: The problem id.
- question_fronted_id: The problem id in the LeetCode front-end.
- difficulty: The difficulty level of the problem, one of "Easy", "Medium", and "Hard".
Level | Numbers |
---|---|
Easy | 20 |
Medium | 39 |
Hard | 21 |
- contest: The name of the contest that include the problem.
- prompt: The problem description with the example input and output removed.
- entry_point: The function name.
- solution: The Python solution for the problem.
- tests: The main test cases, used to verify the correctness of the generated code.
- challenge_tests: Some large scale test cases that be used to further verify the performance of the code.
- public_tests: The public test cases extracted from the problem description.
- prompt_full: The original problem description.
An Example of a Dataset Instance
{
"index": 0,
"title": "Count Pairs That Form a Complete Day I",
"title_slug": "count-pairs-that-form-a-complete-day-i",
"question_id": "3421",
"question_frontend_id": "3184",
"difficulty": "Easy",
"contest": "weekly-contest-402",
"prompt": "from typing import List\n\ndef countCompleteDayPairs(hours: List[int]) -> int:\n \"\"\"\n Given an integer array `hours` representing times in **hours** , return an\n integer denoting the number of pairs `i`, `j` where `i < j` and `hours[i] +\n hours[j]` forms a **complete day**.\n \n A **complete day** is defined as a time duration that is an **exact**\n **multiple** of 24 hours. \n \n **Constraints:**\n \n * `1 <= hours.length <= 100`\n * `1 <= hours[i] <= 10 ^ 9`\n \"\"\"",
"entry_point": "countCompleteDayPairs",
"solution": "from typing import List\nfrom collections import Counter\n\ndef countCompleteDayPairs(hours: List[int]) -> int:\n ctr = Counter(map(lambda x: x % 24, hours))\n count = sum(ctr[i] * ctr[24 - i] for i in range(1, 12))\n return count + (ctr[12] * (ctr[12] - 1) + ctr[0] * (ctr[0] - 1)) // 2",
"tests": ["assert countCompleteDayPairs([12, 12, 30, 24, 24]) == 2", ...], // about 500 test cases
"challenge_tests": [],
"public_tests": ["assert countCompleteDayPairs([12, 12, 30, 24, 24]) == 2", "assert countCompleteDayPairs([72, 48, 24, 3]) == 3"],
"prompt_full": "from typing import List\n\ndef countCompleteDayPairs(hours: List[int]) -> int:\n \"\"\"\n Given an integer array `hours` representing times in **hours** , return an\n integer denoting the number of pairs `i`, `j` where `i < j` and `hours[i] +\n hours[j]` forms a **complete day**.\n \n A **complete day** is defined as a time duration that is an **exact**\n **multiple** of 24 hours.\n \n For example, 1 day is 24 hours, 2 days is 48 hours, 3 days is 72 hours, and so\n on.\n \n \n \n **Example 1:**\n \n **Input:** hours = [12,12,30,24,24]\n \n **Output:** 2\n \n **Explanation:**\n \n The pairs of indices that form a complete day are `(0, 1)` and `(3, 4)`.\n \n **Example 2:**\n \n **Input:** hours = [72,48,24,3]\n \n **Output:** 3\n \n **Explanation:**\n \n The pairs of indices that form a complete day are `(0, 1)`, `(0, 2)`, and `(1,\n 2)`.\n \n \n \n **Constraints:**\n \n * `1 <= hours.length <= 100`\n * `1 <= hours[i] <= 10 ^ 9`\n \"\"\""
}
- prompt
from typing import List
def countCompleteDayPairs(hours: List[int]) -> int:
"""
Given an integer array `hours` representing times in **hours** , return an
integer denoting the number of pairs `i`, `j` where `i < j` and `hours[i] +
hours[j]` forms a **complete day**.
A **complete day** is defined as a time duration that is an **exact**
**multiple** of 24 hours.
**Constraints:**
* `1 <= hours.length <= 100`
* `1 <= hours[i] <= 10 ^ 9`
"""
- test
assert countCompleteDayPairs([12, 12, 30, 24, 24]) == 2