Datasets:
Update README.md
Browse files
README.md
CHANGED
|
@@ -6,4 +6,88 @@ language:
|
|
| 6 |
- en
|
| 7 |
tags:
|
| 8 |
- code
|
| 9 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
- en
|
| 7 |
tags:
|
| 8 |
- code
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# LeetCode-Contest
|
| 12 |
+
|
| 13 |
+
Contains 80 questions of LeetCode weekly and bi-weekly contests released after **March 2024**.
|
| 14 |
+
|
| 15 |
+
Each question contains an average of 644 test cases, as well as programming solutions in Python language collected from the official LeetCode website.
|
| 16 |
+
|
| 17 |
+
## Dataset Structure
|
| 18 |
+
|
| 19 |
+
### Dataset Fields
|
| 20 |
+
|
| 21 |
+
- index: The problem numbers in the dataset, from 0 to 79.
|
| 22 |
+
- title: The title of the problem.
|
| 23 |
+
- title_slug: The title name connected by "_".
|
| 24 |
+
- question_id: The problem id.
|
| 25 |
+
- question_fronted_id: The problem id in the LeetCode front-end.
|
| 26 |
+
- difficulty: The difficulty level of the problem, one of "Easy", "Medium", and "Hard".
|
| 27 |
+
|
| 28 |
+
| Level | Numbers |
|
| 29 |
+
| - | - |
|
| 30 |
+
| Easy | 20 |
|
| 31 |
+
| Medium | 39 |
|
| 32 |
+
| Hard | 21 |
|
| 33 |
+
| | |
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
- contest: The name of the contest that include the problem.
|
| 37 |
+
- prompt: The problem description with the example input and output removed.
|
| 38 |
+
- entry_point: The function name.
|
| 39 |
+
- solution: The Python solution for the problem.
|
| 40 |
+
- tests: The main test cases, used to verify the correctness of the generated code.
|
| 41 |
+
- challenge_tests: Some large scale test cases that be used to further verify the performance of the code.
|
| 42 |
+
- public_tests: The public test cases extracted from the problem description.
|
| 43 |
+
- prompt_full: The original problem description.
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
### An Example of a Dataset Instance
|
| 47 |
+
|
| 48 |
+
```json
|
| 49 |
+
{
|
| 50 |
+
"index": 0,
|
| 51 |
+
"title": "Count Pairs That Form a Complete Day I",
|
| 52 |
+
"title_slug": "count-pairs-that-form-a-complete-day-i",
|
| 53 |
+
"question_id": "3421",
|
| 54 |
+
"question_frontend_id": "3184",
|
| 55 |
+
"difficulty": "Easy",
|
| 56 |
+
"contest": "weekly-contest-402",
|
| 57 |
+
"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 \"\"\"",
|
| 58 |
+
"entry_point": "countCompleteDayPairs",
|
| 59 |
+
"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",
|
| 60 |
+
"tests": ["assert countCompleteDayPairs([12, 12, 30, 24, 24]) == 2", ...], // about 500 test cases
|
| 61 |
+
"challenge_tests": [],
|
| 62 |
+
"public_tests": ["assert countCompleteDayPairs([12, 12, 30, 24, 24]) == 2", "assert countCompleteDayPairs([72, 48, 24, 3]) == 3"],
|
| 63 |
+
"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 \"\"\""
|
| 64 |
+
}
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
- prompt
|
| 69 |
+
|
| 70 |
+
```python
|
| 71 |
+
from typing import List
|
| 72 |
+
|
| 73 |
+
def countCompleteDayPairs(hours: List[int]) -> int:
|
| 74 |
+
"""
|
| 75 |
+
Given an integer array `hours` representing times in **hours** , return an
|
| 76 |
+
integer denoting the number of pairs `i`, `j` where `i < j` and `hours[i] +
|
| 77 |
+
hours[j]` forms a **complete day**.
|
| 78 |
+
|
| 79 |
+
A **complete day** is defined as a time duration that is an **exact**
|
| 80 |
+
**multiple** of 24 hours.
|
| 81 |
+
|
| 82 |
+
**Constraints:**
|
| 83 |
+
|
| 84 |
+
* `1 <= hours.length <= 100`
|
| 85 |
+
* `1 <= hours[i] <= 10 ^ 9`
|
| 86 |
+
"""
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
- test
|
| 90 |
+
```python
|
| 91 |
+
assert countCompleteDayPairs([12, 12, 30, 24, 24]) == 2
|
| 92 |
+
```
|
| 93 |
+
|