Dataset Viewer
Auto-converted to Parquet Duplicate
task_id
stringlengths
33
83
url
stringlengths
44
94
title
stringlengths
14
64
meta
dict
prompt
stringlengths
399
2.26k
prompt_sft
stringlengths
424
2.29k
test
stringlengths
8.25k
44.9k
start_time
int64
1.69B
1.71B
weekly-contest-381-minimum-number-of-pushes-to-type-word-i
https://leetcode.com/problems/minimum-number-of-pushes-to-type-word-i
minimum-number-of-pushes-to-type-word-i
{ "questionId": "3275", "questionFrontendId": "3014", "title": "Minimum Number of Pushes to Type Word I", "titleSlug": "minimum-number-of-pushes-to-type-word-i", "isPaidOnly": false, "difficulty": "Easy", "likes": 39, "dislikes": 7, "categoryTitle": "Algorithms" }
""" 给你一个字符串 word,由 不同 小写英文字母组成。 电话键盘上的按键与 不同 小写英文字母集合相映射,可以通过按压按键来组成单词。例如,按键 2 对应 ["a","b","c"],我们需要按一次键来输入 "a",按两次键来输入 "b",按三次键来输入 "c"。 现在允许你将编号为 2 到 9 的按键重新映射到 不同 字母集合。每个按键可以映射到 任意数量 的字母,但每个字母 必须 恰好 映射到 一个 按键上。你需要找到输入字符串 word 所需的 最少 按键次数。 返回重新映射按键后输入 word 所需的 最少 按键次数。 下面给出了一种电话键盘上字母到按键的映射作为示例。注意 1,*,# 和 0 不 对应任何字母。 ...
给你一个字符串 word,由 不同 小写英文字母组成。 电话键盘上的按键与 不同 小写英文字母集合相映射,可以通过按压按键来组成单词。例如,按键 2 对应 ["a","b","c"],我们需要按一次键来输入 "a",按两次键来输入 "b",按三次键来输入 "c"。 现在允许你将编号为 2 到 9 的按键重新映射到 不同 字母集合。每个按键可以映射到 任意数量 的字母,但每个字母 必须 恰好 映射到 一个 按键上。你需要找到输入字符串 word 所需的 最少 按键次数。 返回重新映射按键后输入 word 所需的 最少 按键次数。 下面给出了一种电话键盘上字母到按键的映射作为示例。注意 1,*,# 和 0 不 对应任何字母。 示例 ...
my_solution = Solution() test_input = { "word": "abcde" } assert my_solution.minimumPushes(**test_input) == 5 test_input = { "word": "xycdefghij" } assert my_solution.minimumPushes(**test_input) == 12 test_input = { "word": "b" } assert my_solution.minimumPushes(**test_input) == 1 test_input = { "word": "d" } asse...
1,705,804,200
weekly-contest-381-count-the-number-of-houses-at-a-certain-distance-i
https://leetcode.com/problems/count-the-number-of-houses-at-a-certain-distance-i
count-the-number-of-houses-at-a-certain-distance-i
{ "questionId": "3271", "questionFrontendId": "3015", "title": "Count the Number of Houses at a Certain Distance I", "titleSlug": "count-the-number-of-houses-at-a-certain-distance-i", "isPaidOnly": false, "difficulty": "Medium", "likes": 62, "dislikes": 7, "categoryTitle": "Algorithms" }
""" 给你三个 正整数 n 、x 和 y 。 在城市中,存在编号从 1 到 n 的房屋,由 n 条街道相连。对所有 1 <= i < n ,都存在一条街道连接编号为 i 的房屋与编号为 i + 1 的房屋。另存在一条街道连接编号为 x 的房屋与编号为 y 的房屋。 对于每个 k(1 <= k <= n),你需要找出所有满足要求的 房屋对 [house1, house2] ,即从 house1 到 house2 需要经过的 最少 街道数为 k 。 返回一个下标从 1 开始且长度为 n 的数组 result ,其中 result[k] 表示所有满足要求的房屋对的数量,即从一个房屋到另一个房屋需要经过的 最少 街道数为 k 。 注意,x...
给你三个 正整数 n 、x 和 y 。 在城市中,存在编号从 1 到 n 的房屋,由 n 条街道相连。对所有 1 <= i < n ,都存在一条街道连接编号为 i 的房屋与编号为 i + 1 的房屋。另存在一条街道连接编号为 x 的房屋与编号为 y 的房屋。 对于每个 k(1 <= k <= n),你需要找出所有满足要求的 房屋对 [house1, house2] ,即从 house1 到 house2 需要经过的 最少 街道数为 k 。 返回一个下标从 1 开始且长度为 n 的数组 result ,其中 result[k] 表示所有满足要求的房屋对的数量,即从一个房屋到另一个房屋需要经过的 最少 街道数为 k 。 注意,x 与 y...
my_solution = Solution() test_input = { "n": 3, "x": 1, "y": 3 } assert my_solution.countOfPairs(**test_input) == [6,0,0] test_input = { "n": 5, "x": 2, "y": 4 } assert my_solution.countOfPairs(**test_input) == [10,8,2,0,0] test_input = { "n": 4, "x": 1, "y": 1 } assert my_solution.countOfPairs(**test_input) == [6,...
1,705,804,200
weekly-contest-381-minimum-number-of-pushes-to-type-word-ii
https://leetcode.com/problems/minimum-number-of-pushes-to-type-word-ii
minimum-number-of-pushes-to-type-word-ii
{ "questionId": "3276", "questionFrontendId": "3016", "title": "Minimum Number of Pushes to Type Word II", "titleSlug": "minimum-number-of-pushes-to-type-word-ii", "isPaidOnly": false, "difficulty": "Medium", "likes": 59, "dislikes": 2, "categoryTitle": "Algorithms" }
""" 给你一个字符串 word,由 不同 小写英文字母组成。 电话键盘上的按键与 不同 小写英文字母集合相映射,可以通过按压按键来组成单词。例如,按键 2 对应 ["a","b","c"],我们需要按一次键来输入 "a",按两次键来输入 "b",按三次键来输入 "c"。 现在允许你将编号为 2 到 9 的按键重新映射到 不同 字母集合。每个按键可以映射到 任意数量 的字母,但每个字母 必须 恰好 映射到 一个 按键上。你需要找到输入字符串 word 所需的 最少 按键次数。 返回重新映射按键后输入 word 所需的 最少 按键次数。 下面给出了一种电话键盘上字母到按键的映射作为示例。注意 1,*,# 和 0 不 对应任何字母。 ...
给你一个字符串 word,由 不同 小写英文字母组成。 电话键盘上的按键与 不同 小写英文字母集合相映射,可以通过按压按键来组成单词。例如,按键 2 对应 ["a","b","c"],我们需要按一次键来输入 "a",按两次键来输入 "b",按三次键来输入 "c"。 现在允许你将编号为 2 到 9 的按键重新映射到 不同 字母集合。每个按键可以映射到 任意数量 的字母,但每个字母 必须 恰好 映射到 一个 按键上。你需要找到输入字符串 word 所需的 最少 按键次数。 返回重新映射按键后输入 word 所需的 最少 按键次数。 下面给出了一种电话键盘上字母到按键的映射作为示例。注意 1,*,# 和 0 不 对应任何字母。 示例 ...
my_solution = Solution() test_input = { "word": "abcde" } assert my_solution.minimumPushes(**test_input) == 5 test_input = { "word": "xyzxyzxyzxyz" } assert my_solution.minimumPushes(**test_input) == 12 test_input = { "word": "aabbccddeeffgghhiiiiii" } assert my_solution.minimumPushes(**test_input) == 24 test_inpu...
1,705,804,200
weekly-contest-381-count-the-number-of-houses-at-a-certain-distance-ii
https://leetcode.com/problems/count-the-number-of-houses-at-a-certain-distance-ii
count-the-number-of-houses-at-a-certain-distance-ii
{ "questionId": "3310", "questionFrontendId": "3017", "title": "Count the Number of Houses at a Certain Distance II", "titleSlug": "count-the-number-of-houses-at-a-certain-distance-ii", "isPaidOnly": false, "difficulty": "Hard", "likes": 27, "dislikes": 12, "categoryTitle": "Algorithms" }
""" 给你三个 正整数 n 、x 和 y 。 在城市中,存在编号从 1 到 n 的房屋,由 n 条街道相连。对所有 1 <= i < n ,都存在一条街道连接编号为 i 的房屋与编号为 i + 1 的房屋。另存在一条街道连接编号为 x 的房屋与编号为 y 的房屋。 对于每个 k(1 <= k <= n),你需要找出所有满足要求的 房屋对 [house1, house2] ,即从 house1 到 house2 需要经过的 最少 街道数为 k 。 返回一个下标从 1 开始且长度为 n 的数组 result ,其中 result[k] 表示所有满足要求的房屋对的数量,即从一个房屋到另一个房屋需要经过的 最少 街道数为 k 。 注意,x...
给你三个 正整数 n 、x 和 y 。 在城市中,存在编号从 1 到 n 的房屋,由 n 条街道相连。对所有 1 <= i < n ,都存在一条街道连接编号为 i 的房屋与编号为 i + 1 的房屋。另存在一条街道连接编号为 x 的房屋与编号为 y 的房屋。 对于每个 k(1 <= k <= n),你需要找出所有满足要求的 房屋对 [house1, house2] ,即从 house1 到 house2 需要经过的 最少 街道数为 k 。 返回一个下标从 1 开始且长度为 n 的数组 result ,其中 result[k] 表示所有满足要求的房屋对的数量,即从一个房屋到另一个房屋需要经过的 最少 街道数为 k 。 注意,x 与 y...
my_solution = Solution() test_input = { "n": 3, "x": 1, "y": 3 } assert my_solution.countOfPairs(**test_input) == [6,0,0] test_input = { "n": 5, "x": 2, "y": 4 } assert my_solution.countOfPairs(**test_input) == [10,8,2,0,0] test_input = { "n": 4, "x": 1, "y": 1 } assert my_solution.countOfPairs(**test_input) == [6,...
1,705,804,200
biweekly-contest-122-divide-an-array-into-subarrays-with-minimum-cost-i
https://leetcode.com/problems/divide-an-array-into-subarrays-with-minimum-cost-i
divide-an-array-into-subarrays-with-minimum-cost-i
{ "questionId": "3263", "questionFrontendId": "3010", "title": "Divide an Array Into Subarrays With Minimum Cost I", "titleSlug": "divide-an-array-into-subarrays-with-minimum-cost-i", "isPaidOnly": false, "difficulty": "Easy", "likes": 40, "dislikes": 2, "categoryTitle": "Algorithms" }
""" 给你一个长度为 n的整数数组nums。 一个数组的 代价是它的 第一个元素。比方说,[1,2,3]的代价是1,[3,4,1]的代价是3。 你需要将nums分成3个连续且没有交集的子数组。 请你返回这些子数组的 最小代价总和。 示例 1: 输入:nums = [1,2,3,12] 输出:6 解释:最佳分割成 3 个子数组的方案是:[1] ,[2] 和 [3,12] ,总代价为 1 + 2 + 3 = 6 。 其他得到 3 个子数组的方案是: - [1] ,[2,3] 和 [12] ,总代价是 1 + 2 + 12 = 15 。 - [1,2] ,[3] 和 [12] ,总代价是 1 + 3 + 12 = 16 。 示例 ...
给你一个长度为 n的整数数组nums。 一个数组的 代价是它的 第一个元素。比方说,[1,2,3]的代价是1,[3,4,1]的代价是3。 你需要将nums分成3个连续且没有交集的子数组。 请你返回这些子数组的 最小代价总和。 示例 1: 输入:nums = [1,2,3,12] 输出:6 解释:最佳分割成 3 个子数组的方案是:[1] ,[2] 和 [3,12] ,总代价为 1 + 2 + 3 = 6 。 其他得到 3 个子数组的方案是: - [1] ,[2,3] 和 [12] ,总代价是 1 + 2 + 12 = 15 。 - [1,2] ,[3] 和 [12] ,总代价是 1 + 3 + 12 = 16 。 示例 2: ...
my_solution = Solution() test_input = { "nums": [1,2,3,12] } assert my_solution.minimumCost(**test_input) == 6 test_input = { "nums": [5,4,3] } assert my_solution.minimumCost(**test_input) == 12 test_input = { "nums": [10,3,1,1] } assert my_solution.minimumCost(**test_input) == 12 test_input = { "nums": [1,1,1] } ...
1,705,761,000
biweekly-contest-122-find-if-array-can-be-sorted
https://leetcode.com/problems/find-if-array-can-be-sorted
find-if-array-can-be-sorted
{ "questionId": "3291", "questionFrontendId": "3011", "title": "Find if Array Can Be Sorted", "titleSlug": "find-if-array-can-be-sorted", "isPaidOnly": false, "difficulty": "Medium", "likes": 52, "dislikes": 7, "categoryTitle": "Algorithms" }
""" 给你一个下标从 0开始且全是 正整数的数组nums。 一次 操作中,如果两个 相邻元素在二进制下数位为 1的数目 相同,那么你可以将这两个元素交换。你可以执行这个操作 任意次(也可以 0 次)。 如果你可以使数组变有序,请你返回true ,否则返回false。 示例 1: 输入:nums = [8,4,2,30,15] 输出:true 解释:我们先观察每个元素的二进制表示。 2 ,4 和 8 分别都只有一个数位为 1 ,分别为 "10" ,"100" 和 "1000" 。15 和 30 分别有 4 个数位为 1 :"1111" 和 "11110" 。 我们可以通过 4 个操作使数组有序: - 交换 nums[0] 和 n...
给你一个下标从 0开始且全是 正整数的数组nums。 一次 操作中,如果两个 相邻元素在二进制下数位为 1的数目 相同,那么你可以将这两个元素交换。你可以执行这个操作 任意次(也可以 0 次)。 如果你可以使数组变有序,请你返回true ,否则返回false。 示例 1: 输入:nums = [8,4,2,30,15] 输出:true 解释:我们先观察每个元素的二进制表示。 2 ,4 和 8 分别都只有一个数位为 1 ,分别为 "10" ,"100" 和 "1000" 。15 和 30 分别有 4 个数位为 1 :"1111" 和 "11110" 。 我们可以通过 4 个操作使数组有序: - 交换 nums[0] 和 nums[...
my_solution = Solution() test_input = { "nums": [8,4,2,30,15] } assert my_solution.canSortArray(**test_input) == True test_input = { "nums": [1,2,3,4,5] } assert my_solution.canSortArray(**test_input) == True test_input = { "nums": [1] } assert my_solution.canSortArray(**test_input) == True test_input = { "nums": ...
1,705,761,000
biweekly-contest-122-minimize-length-of-array-using-operations
https://leetcode.com/problems/minimize-length-of-array-using-operations
minimize-length-of-array-using-operations
{ "questionId": "3244", "questionFrontendId": "3012", "title": "Minimize Length of Array Using Operations", "titleSlug": "minimize-length-of-array-using-operations", "isPaidOnly": false, "difficulty": "Medium", "likes": 79, "dislikes": 30, "categoryTitle": "Algorithms" }
""" 给你一个下标从 0开始的整数数组nums,它只包含 正整数。 你的任务是通过进行以下操作任意次(可以是 0 次)最小化nums的长度: 在 nums中选择 两个不同的下标i和j,满足nums[i] > 0且nums[j] > 0。 将结果nums[i] % nums[j]插入nums的结尾。 将 nums中下标为i和j的元素删除。 请你返回一个整数,它表示进行任意次操作以后nums的 最小长度。 示例 1: 输入:nums = [1,4,3,1] 输出:1 解释:使数组长度最小的一种方法是: 操作 1 :选择下标 2 和 1 ,插入 nums[2] % nums[1] 到数组末尾,得到 [1,4,3,1,3] ,然后...
给你一个下标从 0开始的整数数组nums,它只包含 正整数。 你的任务是通过进行以下操作任意次(可以是 0 次)最小化nums的长度: 在 nums中选择 两个不同的下标i和j,满足nums[i] > 0且nums[j] > 0。 将结果nums[i] % nums[j]插入nums的结尾。 将 nums中下标为i和j的元素删除。 请你返回一个整数,它表示进行任意次操作以后nums的 最小长度。 示例 1: 输入:nums = [1,4,3,1] 输出:1 解释:使数组长度最小的一种方法是: 操作 1 :选择下标 2 和 1 ,插入 nums[2] % nums[1] 到数组末尾,得到 [1,4,3,1,3] ,然后删除下标...
my_solution = Solution() test_input = { "nums": [1,4,3,1] } assert my_solution.minimumArrayLength(**test_input) == 1 test_input = { "nums": [5,5,5,10,5] } assert my_solution.minimumArrayLength(**test_input) == 2 test_input = { "nums": [2,3,4] } assert my_solution.minimumArrayLength(**test_input) == 1 test_input = ...
1,705,761,000
biweekly-contest-122-divide-an-array-into-subarrays-with-minimum-cost-ii
https://leetcode.com/problems/divide-an-array-into-subarrays-with-minimum-cost-ii
divide-an-array-into-subarrays-with-minimum-cost-ii
{ "questionId": "3260", "questionFrontendId": "3013", "title": "Divide an Array Into Subarrays With Minimum Cost II", "titleSlug": "divide-an-array-into-subarrays-with-minimum-cost-ii", "isPaidOnly": false, "difficulty": "Hard", "likes": 54, "dislikes": 2, "categoryTitle": "Algorithms" }
""" 给你一个下标从 0开始长度为 n的整数数组nums和两个 正整数k 和dist。 一个数组的 代价是数组中的 第一个元素。比方说,[1,2,3]的代价为1,[3,4,1]的代价为3。 你需要将 nums分割成 k个 连续且互不相交的子数组,满足 第二个子数组与第 k个子数组中第一个元素的下标距离 不超过dist。换句话说,如果你将nums分割成子数组nums[0..(i1 - 1)], nums[i1..(i2 - 1)], ..., nums[ik-1..(n - 1)],那么它需要满足ik-1 - i1 <= dist。 请你返回这些子数组的 最小总代价。 示例 1: 输入:nums = [1,3,2,6,4,2],...
给你一个下标从 0开始长度为 n的整数数组nums和两个 正整数k 和dist。 一个数组的 代价是数组中的 第一个元素。比方说,[1,2,3]的代价为1,[3,4,1]的代价为3。 你需要将 nums分割成 k个 连续且互不相交的子数组,满足 第二个子数组与第 k个子数组中第一个元素的下标距离 不超过dist。换句话说,如果你将nums分割成子数组nums[0..(i1 - 1)], nums[i1..(i2 - 1)], ..., nums[ik-1..(n - 1)],那么它需要满足ik-1 - i1 <= dist。 请你返回这些子数组的 最小总代价。 示例 1: 输入:nums = [1,3,2,6,4,2], k =...
my_solution = Solution() test_input = { "nums": [1,3,2,6,4,2], "k": 3, "dist": 3 } assert my_solution.minimumCost(**test_input) == 5 test_input = { "nums": [10,1,2,2,2,1], "k": 4, "dist": 3 } assert my_solution.minimumCost(**test_input) == 15 test_input = { "nums": [10,8,18,9], "k": 3, "dist": 1 } assert my_solutio...
1,705,761,000
weekly-contest-380-count-elements-with-maximum-frequency
https://leetcode.com/problems/count-elements-with-maximum-frequency
count-elements-with-maximum-frequency
{ "questionId": "3242", "questionFrontendId": "3005", "title": "Count Elements With Maximum Frequency", "titleSlug": "count-elements-with-maximum-frequency", "isPaidOnly": false, "difficulty": "Easy", "likes": 47, "dislikes": 2, "categoryTitle": "Algorithms" }
""" 给你一个由 正整数 组成的数组 nums 。 返回数组 nums 中所有具有 最大 频率的元素的 总频率 。 元素的 频率 是指该元素在数组中出现的次数。 示例 1: 输入:nums = [1,2,2,3,1,4] 输出:4 解释:元素 1 和 2 的频率为 2 ,是数组中的最大频率。 因此具有最大频率的元素在数组中的数量是 4 。 示例 2: 输入:nums = [1,2,3,4,5] 输出:5 解释:数组中的所有元素的频率都为 1 ,是最大频率。 因此具有最大频率的元素在数组中的数量是 5 。 提示: 1 <= nums.length <= 100 1 <= nums[i] <= 100 """ class...
给你一个由 正整数 组成的数组 nums 。 返回数组 nums 中所有具有 最大 频率的元素的 总频率 。 元素的 频率 是指该元素在数组中出现的次数。 示例 1: 输入:nums = [1,2,2,3,1,4] 输出:4 解释:元素 1 和 2 的频率为 2 ,是数组中的最大频率。 因此具有最大频率的元素在数组中的数量是 4 。 示例 2: 输入:nums = [1,2,3,4,5] 输出:5 解释:数组中的所有元素的频率都为 1 ,是最大频率。 因此具有最大频率的元素在数组中的数量是 5 。 提示: 1 <= nums.length <= 100 1 <= nums[i] <= 100 请完成下面的代码来解决...
my_solution = Solution() test_input = { "nums": [1,2,2,3,1,4] } assert my_solution.maxFrequencyElements(**test_input) == 4 test_input = { "nums": [1,2,3,4,5] } assert my_solution.maxFrequencyElements(**test_input) == 5 test_input = { "nums": [15] } assert my_solution.maxFrequencyElements(**test_input) == 1 test_in...
1,705,199,400
weekly-contest-380-find-beautiful-indices-in-the-given-array-i
https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-i
find-beautiful-indices-in-the-given-array-i
{ "questionId": "3245", "questionFrontendId": "3006", "title": "Find Beautiful Indices in the Given Array I", "titleSlug": "find-beautiful-indices-in-the-given-array-i", "isPaidOnly": false, "difficulty": "Medium", "likes": 91, "dislikes": 21, "categoryTitle": "Algorithms" }
""" 给你一个下标从 0 开始的字符串 s 、字符串 a 、字符串 b 和一个整数 k 。 如果下标 i 满足以下条件,则认为它是一个 美丽下标: 0 <= i <= s.length - a.length s[i..(i + a.length - 1)] == a 存在下标 j 使得: 0 <= j <= s.length - b.length s[j..(j + b.length - 1)] == b |j - i| <= k 以数组形式按 从小到大排序 返回美丽下标。 示例 1: 输入:s = "isawsquirrelnearmysquirrelhouseohmy", a = "my", b = "squi...
给你一个下标从 0 开始的字符串 s 、字符串 a 、字符串 b 和一个整数 k 。 如果下标 i 满足以下条件,则认为它是一个 美丽下标: 0 <= i <= s.length - a.length s[i..(i + a.length - 1)] == a 存在下标 j 使得: 0 <= j <= s.length - b.length s[j..(j + b.length - 1)] == b |j - i| <= k 以数组形式按 从小到大排序 返回美丽下标。 示例 1: 输入:s = "isawsquirrelnearmysquirrelhouseohmy", a = "my", b = "squirrel...
my_solution = Solution() test_input = { "s": "isawsquirrelnearmysquirrelhouseohmy", "a": "my", "b": "squirrel", "k": 15 } assert my_solution.beautifulIndices(**test_input) == [16,33] test_input = { "s": "abcd", "a": "a", "b": "a", "k": 4 } assert my_solution.beautifulIndices(**test_input) == [0] test_input = { "s":...
1,705,199,400
weekly-contest-380-maximum-number-that-sum-of-the-prices-is-less-than-or-equal-to-k
https://leetcode.com/problems/maximum-number-that-sum-of-the-prices-is-less-than-or-equal-to-k
maximum-number-that-sum-of-the-prices-is-less-than-or-equal-to-k
{ "questionId": "3240", "questionFrontendId": "3007", "title": "Maximum Number That Sum of the Prices Is Less Than or Equal to K", "titleSlug": "maximum-number-that-sum-of-the-prices-is-less-than-or-equal-to-k", "isPaidOnly": false, "difficulty": "Medium", "likes": 125, "dislikes": 74, "categoryTitle"...
""" 给你一个整数k和一个整数x。 令 s为整数num的下标从 1开始的二进制表示。我们说一个整数num的 价值是满足i % x == 0 且s[i]是 设置位的 i的数目。 请你返回最大整数num,满足从 1到 num的所有整数的 价值和小于等于 k。 注意: 一个整数二进制表示下 设置位是值为 1的数位。 一个整数的二进制表示下标从右到左编号,比方说如果s == 11100,那么s[4] == 1 且s[2] == 0。 示例 1: 输入:k = 9, x = 1 输出:6 解释:数字 1 ,2 ,3 ,4 ,5 和 6 二进制表示分别为 "1" ,"10" ,"11" ,"100" ,"101" 和 "110" 。 ...
给你一个整数k和一个整数x。 令 s为整数num的下标从 1开始的二进制表示。我们说一个整数num的 价值是满足i % x == 0 且s[i]是 设置位的 i的数目。 请你返回最大整数num,满足从 1到 num的所有整数的 价值和小于等于 k。 注意: 一个整数二进制表示下 设置位是值为 1的数位。 一个整数的二进制表示下标从右到左编号,比方说如果s == 11100,那么s[4] == 1 且s[2] == 0。 示例 1: 输入:k = 9, x = 1 输出:6 解释:数字 1 ,2 ,3 ,4 ,5 和 6 二进制表示分别为 "1" ,"10" ,"11" ,"100" ,"101" 和 "110" 。 由于 x...
my_solution = Solution() test_input = { "k": 9, "x": 1 } assert my_solution.findMaximumNumber(**test_input) == 6 test_input = { "k": 7, "x": 2 } assert my_solution.findMaximumNumber(**test_input) == 9 test_input = { "k": 19, "x": 6 } assert my_solution.findMaximumNumber(**test_input) == 50 test_input = { "k": 57, ...
1,705,199,400
weekly-contest-380-find-beautiful-indices-in-the-given-array-ii
https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-ii
find-beautiful-indices-in-the-given-array-ii
{ "questionId": "3303", "questionFrontendId": "3008", "title": "Find Beautiful Indices in the Given Array II", "titleSlug": "find-beautiful-indices-in-the-given-array-ii", "isPaidOnly": false, "difficulty": "Hard", "likes": 101, "dislikes": 9, "categoryTitle": "Algorithms" }
""" 给你一个下标从 0开始的字符串s、字符串a、字符串b和一个整数k。 如果下标 i满足以下条件,则认为它是一个 美丽下标: 0 <= i <= s.length - a.length s[i..(i + a.length - 1)] == a 存在下标j使得: 0 <= j <= s.length - b.length s[j..(j + b.length - 1)] == b |j - i| <= k 以数组形式按从小到大排序返回美丽下标。 示例 1: 输入:s = "isawsquirrelnearmysquirrelhouseohmy", a = "my", b = "squirrel", k = 15 ...
给你一个下标从 0开始的字符串s、字符串a、字符串b和一个整数k。 如果下标 i满足以下条件,则认为它是一个 美丽下标: 0 <= i <= s.length - a.length s[i..(i + a.length - 1)] == a 存在下标j使得: 0 <= j <= s.length - b.length s[j..(j + b.length - 1)] == b |j - i| <= k 以数组形式按从小到大排序返回美丽下标。 示例 1: 输入:s = "isawsquirrelnearmysquirrelhouseohmy", a = "my", b = "squirrel", k = 15 输出:[...
my_solution = Solution() test_input = { "s": "isawsquirrelnearmysquirrelhouseohmy", "a": "my", "b": "squirrel", "k": 15 } assert my_solution.beautifulIndices(**test_input) == [16,33] test_input = { "s": "abcd", "a": "a", "b": "a", "k": 4 } assert my_solution.beautifulIndices(**test_input) == [0] test_input = { "s":...
1,705,199,400
weekly-contest-379-maximum-area-of-longest-diagonal-rectangle
https://leetcode.com/problems/maximum-area-of-longest-diagonal-rectangle
maximum-area-of-longest-diagonal-rectangle
{ "questionId": "3251", "questionFrontendId": "10035", "title": "Maximum Area of Longest Diagonal Rectangle", "titleSlug": "maximum-area-of-longest-diagonal-rectangle", "isPaidOnly": false, "difficulty": "Easy", "likes": 38, "dislikes": 7, "categoryTitle": "Algorithms" }
""" 给你一个下标从 0 开始的二维整数数组 dimensions。 对于所有下标 i(0 <= i < dimensions.length),dimensions[i][0] 表示矩形 i 的长度,而 dimensions[i][1] 表示矩形 i 的宽度。 返回对角线最 长 的矩形的 面积 。如果存在多个对角线长度相同的矩形,返回面积最 大 的矩形的面积。 示例 1: 输入:dimensions = [[9,3],[8,6]] 输出:48 解释: 下标 = 0,长度 = 9,宽度 = 3。对角线长度 = sqrt(9 * 9 + 3 * 3) = sqrt(90) ≈ 9.487。 下标 = 1,长度 = 8,宽度 =...
给你一个下标从 0 开始的二维整数数组 dimensions。 对于所有下标 i(0 <= i < dimensions.length),dimensions[i][0] 表示矩形 i 的长度,而 dimensions[i][1] 表示矩形 i 的宽度。 返回对角线最 长 的矩形的 面积 。如果存在多个对角线长度相同的矩形,返回面积最 大 的矩形的面积。 示例 1: 输入:dimensions = [[9,3],[8,6]] 输出:48 解释: 下标 = 0,长度 = 9,宽度 = 3。对角线长度 = sqrt(9 * 9 + 3 * 3) = sqrt(90) ≈ 9.487。 下标 = 1,长度 = 8,宽度 = 6。对...
my_solution = Solution() test_input = { "dimensions": [[9,3],[8,6]] } assert my_solution.areaOfMaxDiagonal(**test_input) == 48 test_input = { "dimensions": [[3,4],[4,3]] } assert my_solution.areaOfMaxDiagonal(**test_input) == 12 test_input = { "dimensions": [[4,10],[4,9],[9,3],[10,8]] } assert my_solution.areaOfMax...
1,704,594,600
End of preview. Expand in Data Studio

LeetCode Contest Benchmark

A new benchmark for evaluating Code LLMs proposed by DeepSeek-Coder, which consists of the latest algorithm problems of different difficulties.

Usage

git clone https://github.com/deepseek-ai/DeepSeek-Coder.git
cd Evaluation/LeetCode

# Set the model or path here
MODEL="deepseek-ai/deepseek-coder-7b-instruct"

python vllm_inference.py --model_name_or_path $MODEL --saved_path output/20240121-Jul.deepseek-coder-7b-instruct.jsonl

python evaluate_leetcode.py --generation_path output/20240121-Jul.deepseek-coder-7b-instruct.jsonl --result_path output/20240121-Jul.deepseek-coder-7b-instruct.result.jsonl

Citation

@article{guo2024deepseekcoder,
  title   = {DeepSeek-Coder: When the Large Language Model Meets Programming - The Rise of Code Intelligence},
  author  = {Daya Guo and Qihao Zhu and Dejian Yang and Zhenda Xie and Kai Dong and Wentao Zhang and Guanting Chen and Xiao Bi and Y. Wu and Y. K. Li and Fuli Luo and Yingfei Xiong and Wenfeng Liang},
  year    = {2024},
  journal = {arXiv preprint arXiv: 2401.14196}
}
Downloads last month
37

Paper for TechxGenus/LeetCode-Contest-zh

Free AI Image Generator No sign-up. Instant results. Open Now