Dataset Viewer
Auto-converted to Parquet Duplicate
problem_id
int64
122
5k
question
stringlengths
50
14k
solutions
stringlengths
12
1.21M
input_output
stringlengths
0
871k
difficulty
stringclasses
3 values
url
stringlengths
36
108
starter_code
stringlengths
0
1.1k
solutions_list
listlengths
1
990
n_sols
int64
1
990
non_interactive_idx
listlengths
1
929
interaction_reason
listlengths
1
990
requires_input()
bool
1 class
122
There are several cards arranged in a row, and each card has an associated number of points The points are given in the integer array cardPoints. In one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards. Your score is the sum of the points of the cards you have ...
["class Solution:\n def maxScore(self, cardPoints: List[int], k: int) -> int:\n max_score = 0\n curr_score= 0\n init_hand = cardPoints[len(cardPoints)-k:]\n max_score = sum(init_hand)\n curr_score = max_score\n for i in range(k):\n curr_score -= init_hand[i]\n ...
{"fn_name": "maxScore", "inputs": [[[1, 2, 3, 4, 5, 6, 1], 3]], "outputs": [12]}
interview
https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards/
class Solution: def maxScore(self, cardPoints: List[int], k: int) -> int:
[ "class Solution:\n def maxScore(self, cardPoints: List[int], k: int) -> int:\n max_score = 0\n curr_score= 0\n init_hand = cardPoints[len(cardPoints)-k:]\n max_score = sum(init_hand)\n curr_score = max_score\n for i in range(k):\n curr_score -= init_hand[i]\n ...
80
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54...
[ null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null...
false
123
Your music player contains N different songs and she wants to listen to L (not necessarily different) songs during your trip.  You create a playlist so that: Every song is played at least once A song can only be played again only if K other songs have been played Return the number of possible playlists.  As the answe...
["import math\nclass Solution:\n def numMusicPlaylists(self, N: int, L: int, K: int) -> int:\n s=0\n c=0\n r=0\n x=math.factorial(N)\n while(True):\n c=x*((N-r-K)**(L-K))*(-1)**(r)//(math.factorial(N-r-K)*math.factorial(r))\n if(c!=0):\n s=(s+c)...
{"fn_name": "numMusicPlaylists", "inputs": [[3, 3, 1]], "outputs": [6]}
interview
https://leetcode.com/problems/number-of-music-playlists/
class Solution: def numMusicPlaylists(self, N: int, L: int, K: int) -> int:
[ "import math\nclass Solution:\n def numMusicPlaylists(self, N: int, L: int, K: int) -> int:\n s=0\n c=0\n r=0\n x=math.factorial(N)\n while(True):\n c=x*((N-r-K)**(L-K))*(-1)**(r)//(math.factorial(N-r-K)*math.factorial(r))\n if(c!=0):\n s=(s...
36
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 ]
[ null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null ]
false
124
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]). You are given a target value to search. If found in the array return true, otherwise return false. Example 1: Input: nums = [2,5,6,0,0,1,2], target = 0 Output: true ...
["class Solution:\n def search(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: bool\n \"\"\"\n return target in nums\n", "class Solution:\n def search(self, nums, target):\n \"\"\"\n :type nums: List[int]\n ...
{"fn_name": "search", "inputs": [[[2, 5, 6, 0, 0, 1, 2], 0]], "outputs": [true]}
interview
https://leetcode.com/problems/search-in-rotated-sorted-array-ii/
class Solution: def search(self, nums: List[int], target: int) -> bool:
[ "class Solution:\n def search(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: bool\n \"\"\"\n return target in nums\n", "class Solution:\n def search(self, nums, target):\n \"\"\"\n :type nums: List[int]\n ...
15
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ]
[ null, null, null, null, null, null, null, null, null, null, null, null, null, null, null ]
false
125
Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array. Example1: a = 2 b = [3] Result: 8 Example2: a = 2 b = [1,0] Result: 1024 Credits:Special thanks to @Stomach_ache for adding this problem and creating all test cases...
["class Solution:\n def superPow(self, a, b):\n result = 1\n fermatb = (int(''.join(map(str, b)))) % 570\n while fermatb:\n if fermatb & 1:\n result = (result * a) % 1337\n a = (a * a) % 1337\n fermatb >>= 1\n return result", "class...
{"fn_name": "superPow", "inputs": [[2, [3]]], "outputs": [8]}
interview
https://leetcode.com/problems/super-pow/
class Solution: def superPow(self, a: int, b: List[int]) -> int:
[ "class Solution:\n def superPow(self, a, b):\n result = 1\n fermatb = (int(''.join(map(str, b)))) % 570\n while fermatb:\n if fermatb & 1:\n result = (result * a) % 1337\n a = (a * a) % 1337\n fermatb >>= 1\n return result", "...
14
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]
[ null, null, null, null, null, null, null, null, null, null, null, null, null, null ]
false
126
"Given a string s, return the maximum number of ocurrences of any substring under the following rul(...TRUNCATED)
"[\"class Solution:\\n def maxFreq(self, s: str, maxLetters: int, minSize: int, maxSize: int) -> (...TRUNCATED)
{"fn_name": "maxFreq", "inputs": [["\"aababcaab\"", 2, 3, 4]], "outputs": [2]}
interview
https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring/
"\nclass Solution:\n def maxFreq(self, s: str, maxLetters: int, minSize: int, maxSize: int) -> in(...TRUNCATED)
["class Solution:\n def maxFreq(self, s: str, maxLetters: int, minSize: int, maxSize: int) -> int(...TRUNCATED)
205
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,3(...TRUNCATED)
[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null(...TRUNCATED)
false
127
"There is a group of G members, and a list of various crimes they could commit.\nThe ith crime gen(...TRUNCATED)
"[\"class Solution:\\n def profitableSchemes(self, G: int, P: int, group: List[int], profit: List(...TRUNCATED)
{"fn_name": "profitableSchemes", "inputs": [[5, 3, [2, 2], [2, 3]]], "outputs": [2]}
interview
https://leetcode.com/problems/profitable-schemes/
"\nclass Solution:\n def profitableSchemes(self, G: int, P: int, group: List[int], profit: List[i(...TRUNCATED)
["class Solution:\n def profitableSchemes(self, G: int, P: int, group: List[int], profit: List[in(...TRUNCATED)
74
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,3(...TRUNCATED)
[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null(...TRUNCATED)
false
128
"Implement a basic calculator to evaluate a simple expression string.\n\nThe expression string may c(...TRUNCATED)
"[\"class Solution:\\n def calculate(self, s):\\n \\\"\\\"\\\"\\n :type s: str\\(...TRUNCATED)
{"fn_name": "calculate", "inputs": [["\"1 + 1\""]], "outputs": [2]}
interview
https://leetcode.com/problems/basic-calculator/
class Solution: def calculate(self, s: str) -> int:
["class Solution:\n def calculate(self, s):\n \"\"\"\n :type s: str\n :r(...TRUNCATED)
7
[ 0, 1, 2, 3, 4, 5, 6 ]
[ null, null, null, null, null, null, null ]
false
129
"Given an array A of positive integers, A[i] represents the value of the i-th sightseeing spot, and (...TRUNCATED)
"[\"class Solution:\\n def maxScoreSightseeingPair(self, A: List[int]) -> int:\\n curmaxsi(...TRUNCATED)
{"fn_name": "maxScoreSightseeingPair", "inputs": [[[8, 1, 5, 2, 6]]], "outputs": [11]}
interview
https://leetcode.com/problems/best-sightseeing-pair/
class Solution: def maxScoreSightseeingPair(self, A: List[int]) -> int:
["class Solution:\n def maxScoreSightseeingPair(self, A: List[int]) -> int:\n curmaxsight (...TRUNCATED)
78
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,3(...TRUNCATED)
[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null(...TRUNCATED)
false
130
"A program was supposed to print an array of integers. The program forgot to print whitespaces and t(...TRUNCATED)
"[\"class Solution:\\n def numberOfArrays(self, s: str, k: int) -> int:\\n dp = [-1] * len(...TRUNCATED)
{"fn_name": "numberOfArrays", "inputs": [["\"1000\"", 10000]], "outputs": [4]}
interview
https://leetcode.com/problems/restore-the-array/
class Solution: def numberOfArrays(self, s: str, k: int) -> int:
["class Solution:\n def numberOfArrays(self, s: str, k: int) -> int:\n dp = [-1] * len(s)\(...TRUNCATED)
9
[ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
[ null, null, null, null, null, null, null, null, null ]
false
131
"You are given a string expression representing a Lisp-like expression to return the integer value o(...TRUNCATED)
"[\"class Solution(object):\\n \\tdef parse(self,expression,d,i):\\n \\t\\tcount = 0\\n \\t\\tstart (...TRUNCATED)
{"fn_name": "evaluate", "inputs": [["\"(add 1 2)\""]], "outputs": [2]}
interview
https://leetcode.com/problems/parse-lisp-expression/
class Solution: def evaluate(self, expression: str) -> int:
["class Solution(object):\n \tdef parse(self,expression,d,i):\n \t\tcount = 0\n \t\tstart = i\n \t\t(...TRUNCATED)
1
[ 0 ]
[ null ]
false
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
4