question_id int64 1 3.24k | task_id stringlengths 3 77 | difficulty stringclasses 3
values | problem_description stringlengths 193 3.69k | canonical_tests dict | public_tests listlengths 1 5 | hints listlengths 0 8 | metadata dict | language stringclasses 9
values | interface dict |
|---|---|---|---|---|---|---|---|---|---|
2,177 | find-three-consecutive-integers-that-sum-to-a-given-number | Medium | Given an integer num, return three consecutive integers (as a sorted array) that sum to num. If num cannot be expressed as the sum of three consecutive integers, return an empty array.
Example 1:
Input: num = 33
Output: [10,11,12]
Explanation: 33 can be expressed as 10 + 11 + 12 = 33.
10, 11, 12 are 3 consecutive int... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = 9) == [2, 3, 4]\n assert candidate(num = 1000000000001) == []\n assert candidate(num = 0) == [-1, 0, 1]\n assert candidate(num = 4) == []\n assert candidate(num = 33) == [10, 11, 12]\n assert candidate(num = 10000000... | [
"33",
"4"
] | [
"Notice that if a solution exists, we can represent them as x-1, x, x+1. What does this tell us about the number?",
"Notice the sum of the numbers will be 3x. Can you solve for x?"
] | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().sumOfThree",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:43:47",
"tests_total": 52,
"tests_droppe... | typescript | {
"raw_signature": "function sumOfThree(num: number): number[] {",
"container": null,
"callable": "sumOfThree",
"parameters": [
{
"name": "num",
"type": "number"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,178 | maximum-split-of-positive-even-integers | Medium | You are given an integer finalSum. Split it into a sum of a maximum number of unique positive even integers.
- For example, given finalSum = 12, the following splits are valid (unique positive even integers summing up to finalSum): (12), (2 + 10), (2 + 4 + 6), and (4 + 8). Among them, (2 + 4 + 6) contains the maximum ... | {
"language": "python",
"source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ... | [
"12",
"7",
"28"
] | [
"First, check if finalSum is divisible by 2. If it isn’t, then we cannot split it into even integers.",
"Let k be the number of elements in our split. As we want the maximum number of elements, we should try to use the first k - 1 even elements to grow our sum as slowly as possible.",
"Thus, we find the maximum... | {
"canonical_parameter_names": [
"finalSum"
],
"leetcode_dataset_entry_point": "Solution().maximumEvenSplit",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:43:49",
"tests_total": 50,
"t... | typescript | {
"raw_signature": "function maximumEvenSplit(finalSum: number): number[] {",
"container": null,
"callable": "maximumEvenSplit",
"parameters": [
{
"name": "finalSum",
"type": "number"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcod... |
2,179 | count-good-triplets-in-an-array | Hard | You are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1].
A good triplet is a set of 3 distinct values which are present in increasing order by position both in nums1 and nums2. In other words, if we consider pos1_v as the index of the value v in nums1 and po... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [0, 1, 2, 3],nums2 = [3, 2, 1, 0]) == 0\n assert candidate(nums1 = [1, 0, 3, 2],nums2 = [2, 3, 0, 1]) == 0\n assert candidate(nums1 = [2, 0, ... | [
"[2,0,1,3]\n[0,1,2,3]",
"[4,0,1,3,2]\n[4,1,0,2,3]"
] | [
"For every value y, how can you find the number of values x (0 ≤ x, y ≤ n - 1) such that x appears before y in both of the arrays?",
"Similarly, for every value y, try finding the number of values z (0 ≤ y, z ≤ n - 1) such that z appears after y in both of the arrays.",
"Now, for every value y, count the number... | {
"canonical_parameter_names": [
"nums1",
"nums2"
],
"leetcode_dataset_entry_point": "Solution().goodTriplets",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:43:51",
"tests_total": 10... | typescript | {
"raw_signature": "function goodTriplets(nums1: number[], nums2: number[]): number {",
"container": null,
"callable": "goodTriplets",
"parameters": [
{
"name": "nums1",
"type": "number[]"
},
{
"name": "nums2",
"type": "number[]"
}
],
"return_type": "number",
"signa... |
2,180 | count-integers-with-even-digit-sum | Easy | Given a positive integer num, return the number of positive integers less than or equal to num whose digit sums are even.
The digit sum of a positive integer is the sum of all its digits.
Example 1:
Input: num = 4
Output: 2
Explanation:
The only integers less than or equal to 4 whose digit sums are even are 2 and 4.... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = 30) == 14\n assert candidate(num = 10) == 4\n assert candidate(num = 999) == 499\n assert candidate(num = 500) == 249\n assert candidate(num = 4) == 2\n assert candidate(num = 2) == 1\n assert candidate(num = 1) =... | [
"4",
"30"
] | [
"Iterate through all integers from 1 to num.",
"For any integer, extract the individual digits to compute their sum and check if it is even."
] | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().countEven",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:43:54",
"tests_total": 34,
"tests_dropped... | typescript | {
"raw_signature": "function countEven(num: number): number {",
"container": null,
"callable": "countEven",
"parameters": [
{
"name": "num",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,182 | construct-string-with-repeat-limit | Medium | You are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears more than repeatLimit times in a row. You do not have to use all characters from s.
Return the lexicographically largest repeatLimitedString possible.
A string a is lex... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"aabbccddeeff\",repeatLimit = 1) == \"fefedcdcbaba\"\n assert candidate(s = \"aabbccddeeff\",repeatLimit = 3) == \"ffeeddccbbaa\"\n assert candidate(s = \"cczazcc\",repeatLimit = 3) == \"zzcccac\"\n assert candidate(s = \"z... | [
"\"cczazcc\"\n3",
"\"aababab\"\n2"
] | [
"Start constructing the string in descending order of characters.",
"When repeatLimit is reached, pick the next largest character."
] | {
"canonical_parameter_names": [
"s",
"repeatLimit"
],
"leetcode_dataset_entry_point": "Solution().repeatLimitedString",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:43:59",
"tests_t... | typescript | {
"raw_signature": "function repeatLimitedString(s: string, repeatLimit: number): string {",
"container": null,
"callable": "repeatLimitedString",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "repeatLimit",
"type": "number"
}
],
"return_type": "string"... |
2,183 | count-array-pairs-divisible-by-k | Hard | Given a 0-indexed integer array nums of length n and an integer k, return the number of pairs (i, j) such that:
- 0 <= i < j <= n - 1 and
- nums[i] * nums[j] is divisible by k.
Example 1:
Input: nums = [1,2,3,4,5], k = 2
Output: 7
Explanation:
The 7 pairs of indices whose corresponding products are divisible by 2 ar... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7],k = 7) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 10\n assert candidate(nums = [5, 5, 5, 5],k = 5) == 6\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == 7\n assert candidate(nums... | [
"[1,2,3,4,5]\n2",
"[1,2,3,4]\n5"
] | [
"For any element in the array, what is the smallest number it should be multiplied with such that the product is divisible by k?",
"The smallest number which should be multiplied with nums[i] so that the product is divisible by k is k / gcd(k, nums[i]). Now think about how you can store and update the count of su... | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().countPairs",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:01",
"tests_total": 102,
"t... | typescript | {
"raw_signature": "function countPairs(nums: number[], k: number): number {",
"container": null,
"callable": "countPairs",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "lee... |
2,185 | counting-words-with-a-given-prefix | Easy | You are given an array of strings words and a string pref.
Return the number of strings in words that contain pref as a prefix.
A prefix of a string s is any leading contiguous substring of s.
Example 1:
Input: words = ["pay","attention","practice","attend"], pref = "at"
Output: 2
Explanation: The 2 strings that co... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(words = ['test', 'testing', 'tested', 'testing'],pref = \"test\") == 4\n assert candidate(words = ['abc', 'bcd', 'cde'],pref = \"a\") == 1\n assert candidate(words = ['hello', 'world', 'helium', 'helper'],pref = \"hel\") == 3\n ... | [
"[\"pay\",\"attention\",\"practice\",\"attend\"]\n\"at\"",
"[\"leetcode\",\"win\",\"loops\",\"success\"]\n\"code\""
] | [
"Go through each word in words and increment the answer if pref is a prefix of the word."
] | {
"canonical_parameter_names": [
"words",
"pref"
],
"leetcode_dataset_entry_point": "Solution().prefixCount",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:06",
"tests_total": 153,... | typescript | {
"raw_signature": "function prefixCount(words: string[], pref: string): number {",
"container": null,
"callable": "prefixCount",
"parameters": [
{
"name": "words",
"type": "string[]"
},
{
"name": "pref",
"type": "string"
}
],
"return_type": "number",
"signature_sou... |
2,186 | minimum-number-of-steps-to-make-two-strings-anagram-ii | Medium | You are given two strings s and t. In one step, you can append any character to either s or t.
Return the minimum number of steps to make s and t anagrams of each other.
An anagram of a string is a string that contains the same characters with a different (or the same) ordering.
Example 1:
Input: s = "leetcode", t ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"aaaa\",t = \"bbbb\") == 8\n assert candidate(s = \"aabbcc\",t = \"abc\") == 3\n assert candidate(s = \"anagram\",t = \"nagaram\") == 0\n assert candidate(s = \"rat\",t = \"car\") == 2\n assert candidate(s = \"xyz\",t = ... | [
"\"leetcode\"\n\"coats\"",
"\"night\"\n\"thing\""
] | [
"Notice that for anagrams, the order of the letters is irrelevant.",
"For each letter, we can count its frequency in s and t.",
"For each letter, its contribution to the answer is the absolute difference between its frequency in s and t."
] | {
"canonical_parameter_names": [
"s",
"t"
],
"leetcode_dataset_entry_point": "Solution().minSteps",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:09",
"tests_total": 110,
"tests_... | typescript | {
"raw_signature": "function minSteps(s: string, t: string): number {",
"container": null,
"callable": "minSteps",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "t",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnip... |
2,187 | minimum-time-to-complete-trips | Medium | You are given an array time where time[i] denotes the time taken by the i^th bus to complete one trip.
Each bus can make multiple trips successively; that is, the next trip can start immediately after completing the current trip. Also, each bus operates independently; that is, the trips of one bus do not influence the... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(time = [1, 2, 3],totalTrips = 5) == 3\n assert candidate(time = [10000000],totalTrips = 10000000) == 100000000000000\n assert candidate(time = [10, 20, 30],totalTrips = 100) == 550\n assert candidate(time = [1, 1, 1, 1, 1],total... | [
"[1,2,3]\n5",
"[2]\n1"
] | [
"For a given amount of time, how can we count the total number of trips completed by all buses within that time?",
"Consider using binary search."
] | {
"canonical_parameter_names": [
"time",
"totalTrips"
],
"leetcode_dataset_entry_point": "Solution().minimumTime",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:12",
"tests_total":... | typescript | {
"raw_signature": "function minimumTime(time: number[], totalTrips: number): number {",
"container": null,
"callable": "minimumTime",
"parameters": [
{
"name": "time",
"type": "number[]"
},
{
"name": "totalTrips",
"type": "number"
}
],
"return_type": "number",
"sig... |
2,188 | minimum-time-to-finish-the-race | Hard | You are given a 0-indexed 2D integer array tires where tires[i] = [f_i, r_i] indicates that the i^th tire can finish its x^th successive lap in f_i * r_i^(x-1) seconds.
- For example, if f_i = 3 and r_i = 2, then the tire would finish its 1^st lap in 3 seconds, its 2^nd lap in 3 * 2 = 6 seconds, its 3^rd lap in 3 * 2^... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(tires = [[2, 3], [3, 4]],changeTime = 5,numLaps = 4) == 21\n assert candidate(tires = [[5, 2], [3, 3]],changeTime = 4,numLaps = 3) == 17\n assert candidate(tires = [[5, 5], [3, 3]],changeTime = 10,numLaps = 6) == 56\n assert can... | [
"[[2,3],[3,4]]\n5\n4",
"[[1,10],[2,2],[3,4]]\n6\n5"
] | [
"What is the maximum number of times we would want to go around the track without changing tires?",
"Can we precompute the minimum time to go around the track x times without changing tires?",
"Can we use dynamic programming to solve this efficiently using the precomputed values?"
] | {
"canonical_parameter_names": [
"tires",
"changeTime",
"numLaps"
],
"leetcode_dataset_entry_point": "Solution().minimumFinishTime",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44... | typescript | {
"raw_signature": "function minimumFinishTime(tires: number[][], changeTime: number, numLaps: number): number {",
"container": null,
"callable": "minimumFinishTime",
"parameters": [
{
"name": "tires",
"type": "number[][]"
},
{
"name": "changeTime",
"type": "number"
},
... |
2,190 | most-frequent-number-following-key-in-an-array | Easy | You are given a 0-indexed integer array nums. You are also given an integer key, which is present in nums.
For every unique integer target in nums, count the number of times target immediately follows an occurrence of key in nums. In other words, count the number of indices i such that:
- 0 <= i <= nums.length - 2,
-... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],key = 1) == 2\n assert candidate(nums = [1, 2, 2, 3, 2, 1, 2, 4],key = 2) == 2\n assert candidate(nums = [3, 1, 3, 1, 3, 1, 3, 1, 3, 2],key = 1) == 3\n assert candidate(nums = [10, 20, 20, 1... | [
"[1,100,200,1,100]\n1",
"[2,2,2,2,3]\n2"
] | [
"Count the number of times each target value follows the key in the array.",
"Choose the target with the maximum count and return it."
] | {
"canonical_parameter_names": [
"nums",
"key"
],
"leetcode_dataset_entry_point": "Solution().mostFrequent",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:19",
"tests_total": 103,
... | typescript | {
"raw_signature": "function mostFrequent(nums: number[], key: number): number {",
"container": null,
"callable": "mostFrequent",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "key",
"type": "number"
}
],
"return_type": "number",
"signature_sourc... |
2,191 | sort-the-jumbled-numbers | Medium | You are given a 0-indexed integer array mapping which represents the mapping rule of a shuffled decimal system. mapping[i] = j means digit i should be mapped to digit j in this system.
The mapped value of an integer is the new integer obtained by replacing each occurrence of digit i in the integer with mapping[i] for ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(mapping = [5, 8, 9, 2, 1, 6, 7, 0, 3, 4],nums = [345, 123, 678]) == [345, 678, 123]\n assert candidate(mapping = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5],nums = [10, 100, 1000, 10000]) == [10, 100, 1000, 10000]\n assert candidate(mapping = [... | [
"[8,9,4,0,2,1,3,5,7,6]\n[991,338,38]",
"[0,1,2,3,4,5,6,7,8,9]\n[789,456,123]"
] | [
"Map the original numbers to new numbers by the mapping rule and sort the new numbers.",
"To maintain the same relative order for equal mapped values, use the index in the original input array as a tiebreaker."
] | {
"canonical_parameter_names": [
"mapping",
"nums"
],
"leetcode_dataset_entry_point": "Solution().sortJumbled",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:21",
"tests_total": 11... | typescript | {
"raw_signature": "function sortJumbled(mapping: number[], nums: number[]): number[] {",
"container": null,
"callable": "sortJumbled",
"parameters": [
{
"name": "mapping",
"type": "number[]"
},
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number[]",
"s... |
2,192 | all-ancestors-of-a-node-in-a-directed-acyclic-graph | Medium | You are given a positive integer n representing the number of nodes of a Directed Acyclic Graph (DAG). The nodes are numbered from 0 to n - 1 (inclusive).
You are also given a 2D integer array edges, where edges[i] = [from_i, to_i] denotes that there is a unidirectional edge from from_i to to_i in the graph.
Return a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 6,edges = [[0, 2], [2, 3], [1, 3], [4, 5]]) == [[], [], [0], [0, 1, 2], [], [4]]\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3]]) == [[], [0], [0, 1], [0, 1, 2]]\n assert candidate(n = 8,edges = [[0, 3], [0, 4], [1, 3... | [
"8\n[[0,3],[0,4],[1,3],[2,4],[2,7],[3,5],[3,6],[3,7],[4,6]]",
"5\n[[0,1],[0,2],[0,3],[0,4],[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]"
] | [
"Consider how reversing each edge of the graph can help us.",
"How can performing BFS/DFS on the reversed graph help us find the ancestors of every node?"
] | {
"canonical_parameter_names": [
"n",
"edges"
],
"leetcode_dataset_entry_point": "Solution().getAncestors",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:24",
"tests_total": 63,
... | typescript | {
"raw_signature": "function getAncestors(n: number, edges: number[][]): number[][] {",
"container": null,
"callable": "getAncestors",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "edges",
"type": "number[][]"
}
],
"return_type": "number[][]",
"signa... |
2,193 | minimum-number-of-moves-to-make-palindrome | Hard | You are given a string s consisting only of lowercase English letters.
In one move, you can select any two adjacent characters of s and swap them.
Return the minimum number of moves needed to make s a palindrome.
Note that the input will be generated such that s can always be converted to a palindrome.
Example 1:
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abcba\") == 0\n assert candidate(s = \"letelt\") == 2\n assert candidate(s = \"abcdcba\") == 0\n assert candidate(s = \"aabbaa\") == 0\n assert candidate(s = \"abcdedcba\") == 0\n assert candidate(s = \"mamad\") == 3... | [
"\"aabb\"",
"\"letelt\""
] | [
"Consider a greedy strategy.",
"Let’s start by making the leftmost and rightmost characters match with some number of swaps.",
"If we figure out how to do that using the minimum number of swaps, then we can delete the leftmost and rightmost characters and solve the problem recursively."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().minMovesToMakePalindrome",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:26",
"tests_total": 105,
... | typescript | {
"raw_signature": "function minMovesToMakePalindrome(s: string): number {",
"container": null,
"callable": "minMovesToMakePalindrome",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
2,194 | cells-in-a-range-on-an-excel-sheet | Easy | A cell (r, c) of an excel sheet is represented as a string "<col><row>" where:
- <col> denotes the column number c of the cell. It is represented by alphabetical letters.
- For example, the 1^st column is denoted by 'A', the 2^nd by 'B', the 3^rd by 'C', and so on.
- <row> is the row number r of the cell. The r^th r... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"D4:H6\") == ['D4', 'D5', 'D6', 'E4', 'E5', 'E6', 'F4', 'F5', 'F6', 'G4', 'G5', 'G6', 'H4', 'H5', 'H6']\n assert candidate(s = \"K1:L2\") == ['K1', 'K2', 'L1', 'L2']\n assert candidate(s = \"A1:F1\") == ['A1', 'B1', 'C1', 'D1'... | [
"\"K1:L2\"",
"\"A1:F1\""
] | [
"From the given string, find the corresponding rows and columns.",
"Iterate through the columns in ascending order and for each column, iterate through the rows in ascending order to obtain the required cells in sorted order."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().cellsInRange",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:28",
"tests_total": 175,
"tests_dropp... | typescript | {
"raw_signature": "function cellsInRange(s: string): string[] {",
"container": null,
"callable": "cellsInRange",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,195 | append-k-integers-with-minimal-sum | Medium | You are given an integer array nums and an integer k. Append k unique positive integers that do not appear in nums to nums such that the resulting total sum is minimum.
Return the sum of the k integers appended to nums.
Example 1:
Input: nums = [1,4,25,10,25], k = 2
Output: 5
Explanation: The two unique positive int... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 21\n assert candidate(nums = [1, 4, 25, 10, 25],k = 2) == 5\n assert candidate(nums = [1000000000],k = 100000) == 5000050000\n assert candidate(nums = [1000000000],k = 1) == 1\n assert candida... | [
"[1,4,25,10,25]\n2",
"[5,6]\n6"
] | [
"The k smallest numbers that do not appear in nums will result in the minimum sum.",
"Recall that the sum of the first n positive numbers is equal to n * (n+1) / 2.",
"Initialize the answer as the sum of 1 to k. Then, adjust the answer depending on the values in nums."
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().minimalKSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:30",
"tests_total": 111,
"... | typescript | {
"raw_signature": "function minimalKSum(nums: number[], k: number): number {",
"container": null,
"callable": "minimalKSum",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "l... |
2,197 | replace-non-coprime-numbers-in-array | Hard | You are given an array of integers nums. Perform the following steps:
1. Find any two adjacent numbers in nums that are non-coprime.
2. If no such numbers are found, stop the process.
3. Otherwise, delete the two numbers and replace them with their LCM (Least Common Multiple).
4. Repeat this process as long as you kee... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [4, 6, 8, 10, 12]) == [120]\n assert candidate(nums = [100000, 100000, 100000, 100000]) == [100000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [... | [
"[6,4,3,2,7,6,2]",
"[2,2,1,1,3,3,3]"
] | [
"Notice that the order of merging two numbers into their LCM does not matter so we can greedily merge elements to its left if possible.",
"If a new value is formed, we should recursively check if it can be merged with the value to its left.",
"To simulate the merge efficiently, we can maintain a stack that stor... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().replaceNonCoprimes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:36",
"tests_total": 134,
"te... | typescript | {
"raw_signature": "function replaceNonCoprimes(nums: number[]): number[] {",
"container": null,
"callable": "replaceNonCoprimes",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcod... |
2,200 | find-all-k-distant-indices-in-an-array | Easy | You are given a 0-indexed integer array nums and two integers key and k. A k-distant index is an index i of nums for which there exists at least one index j such that |i - j| <= k and nums[j] == key.
Return a list of all k-distant indices sorted in increasing order.
Example 1:
Input: nums = [3,4,9,1,3,9,5], key = 9,... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 1, 4, 1, 5],key = 5,k = 2) == [0, 1, 2, 3, 4]\n assert candidate(nums = [1, 1, 1, 1, 1, 1],key = 1,k = 3) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [1, 3, 5, 7, 9],key = 3,k = 2) == [0, 1, 2, 3]\n assert candida... | [
"[3,4,9,1,3,9,5]\n9\n1",
"[2,2,2,2,2]\n2\n2"
] | [
"For every occurrence of key in nums, find all indices within distance k from it.",
"Use a hash table to remove duplicate indices."
] | {
"canonical_parameter_names": [
"nums",
"key",
"k"
],
"leetcode_dataset_entry_point": "Solution().findKDistantIndices",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:40",
"tes... | typescript | {
"raw_signature": "function findKDistantIndices(nums: number[], key: number, k: number): number[] {",
"container": null,
"callable": "findKDistantIndices",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "key",
"type": "number"
},
{
"name": "k... |
2,201 | count-artifacts-that-can-be-extracted | Medium | There is an n x n 0-indexed grid with some artifacts buried in it. You are given the integer n and a 0-indexed 2D integer array artifacts describing the positions of the rectangular artifacts where artifacts[i] = [r1_i, c1_i, r2_i, c2_i] denotes that the i^th artifact is buried in the subgrid where:
- (r1_i, c1_i) is ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 4,artifacts = [[0, 0, 0, 0], [1, 1, 2, 2], [3, 3, 3, 3]],dig = [[0, 0], [1, 1], [2, 2], [3, 3]]) == 2\n assert candidate(n = 5,artifacts = [[0, 0, 0, 1], [1, 1, 2, 2], [3, 3, 4, 4]],dig = [[0, 0], [0, 1], [1, 1], [1, 2], [2, 1], [... | [
"2\n[[0,0,0,0],[0,1,1,1]]\n[[0,0],[0,1]]",
"2\n[[0,0,0,0],[0,1,1,1]]\n[[0,0],[0,1],[1,1]]"
] | [
"Check if each coordinate of each artifact has been excavated. How can we do this quickly without iterating over the dig array every time?",
"Consider marking all excavated cells in a 2D boolean array."
] | {
"canonical_parameter_names": [
"n",
"artifacts",
"dig"
],
"leetcode_dataset_entry_point": "Solution().digArtifacts",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:43",
"tests... | typescript | {
"raw_signature": "function digArtifacts(n: number, artifacts: number[][], dig: number[][]): number {",
"container": null,
"callable": "digArtifacts",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "artifacts",
"type": "number[][]"
},
{
"name": "d... |
2,202 | maximize-the-topmost-element-after-k-moves | Medium | You are given a 0-indexed integer array nums representing the contents of a pile, where nums[0] is the topmost element of the pile.
In one move, you can perform either of the following:
- If the pile is not empty, remove the topmost element of the pile.
- If there are one or more removed elements, add any one of them... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7],k = 2) == 7\n assert candidate(nums = [9, 8, 7, 6, 5],k = 5) == 9\n assert candidate(nums = [10],k = 2) == 10\n assert candidate(nums = [8, 6, 4, 2, 0],k = 7) == 8\n assert candidate(nums = [7, 7, 7, 7,... | [
"[5,2,2,4,0,6]\n4",
"[2]\n1"
] | [
"For each index i, how can we check if nums[i] can be present at the top of the pile or not after k moves?",
"For which conditions will we end up with an empty pile?"
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().maximumTop",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:45",
"tests_total": 148,
"t... | typescript | {
"raw_signature": "function maximumTop(nums: number[], k: number): number {",
"container": null,
"callable": "maximumTop",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "lee... |
2,203 | minimum-weighted-subgraph-with-the-required-paths | Hard | You are given an integer n denoting the number of nodes of a weighted directed graph. The nodes are numbered from 0 to n - 1.
You are also given a 2D integer array edges where edges[i] = [from_i, to_i, weight_i] denotes that there exists a directed edge from from_i to to_i with weight weight_i.
Lastly, you are given ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 6,edges = [[0, 2, 2], [0, 5, 6], [1, 0, 3], [1, 4, 5], [2, 1, 1], [2, 3, 3], [2, 3, 4], [3, 4, 2], [4, 5, 1]],src1 = 0,src2 = 1,dest = 5) == 9\n assert candidate(n = 6,edges = [[1, 2, 2], [1, 3, 1], [2, 4, 5], [3, 4, 3], [4, 5, 2]... | [
"6\n[[0,2,2],[0,5,6],[1,0,3],[1,4,5],[2,1,1],[2,3,3],[2,3,4],[3,4,2],[4,5,1]]\n0\n1\n5",
"3\n[[0,1,1],[2,1,1]]\n0\n1\n2"
] | [
"Consider what the paths from src1 to dest and src2 to dest would look like in the optimal solution.",
"It can be shown that in an optimal solution, the two paths from src1 and src2 will coincide at one node, and the remaining part to dest will be the same for both paths. Now consider how to find the node where t... | {
"canonical_parameter_names": [
"n",
"edges",
"src1",
"src2",
"dest"
],
"leetcode_dataset_entry_point": "Solution().minimumWeight",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-... | typescript | {
"raw_signature": "function minimumWeight(n: number, edges: number[][], src1: number, src2: number, dest: number): number {",
"container": null,
"callable": "minimumWeight",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "edges",
"type": "number[][]"
},
... |
2,206 | divide-array-into-equal-pairs | Easy | You are given an integer array nums consisting of 2 * n integers.
You need to divide nums into n pairs such that:
- Each element belongs to exactly one pair.
- The elements present in a pair are equal.
Return true if nums can be divided into n pairs, otherwise return false.
Example 1:
Input: nums = [3,2,3,2,2,2]
O... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4]) == True\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 2, 1, 3, 2, 3]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == True\n assert c... | [
"[3,2,3,2,2,2]",
"[1,2,3,4]"
] | [
"For any number x in the range [1, 500], count the number of elements in nums whose values are equal to x.",
"The elements with equal value can be divided completely into pairs if and only if their count is even."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().divideArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:52",
"tests_total": 91,
"tests_drop... | typescript | {
"raw_signature": "function divideArray(nums: number[]): boolean {",
"container": null,
"callable": "divideArray",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
2,207 | maximize-number-of-subsequences-in-a-string | Medium | You are given a 0-indexed string text and another 0-indexed string pattern of length 2, both of which consist of only lowercase English letters.
You can add either pattern[0] or pattern[1] anywhere in text exactly once. Note that the character can be added even at the beginning or at the end of text.
Return the maxim... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(text = \"bbbb\",pattern = \"bb\") == 10\n assert candidate(text = \"aaaaa\",pattern = \"aa\") == 15\n assert candidate(text = \"zzzz\",pattern = \"zz\") == 10\n assert candidate(text = \"abdcdbc\",pattern = \"ac\") == 4\n ass... | [
"\"abdcdbc\"\n\"ac\"",
"\"aabb\"\n\"ab\""
] | [
"Find the optimal position to add pattern[0] so that the number of subsequences is maximized. Similarly, find the optimal position to add pattern[1].",
"For each of the above cases, count the number of times the pattern occurs as a subsequence in text. The larger count is the required answer."
] | {
"canonical_parameter_names": [
"text",
"pattern"
],
"leetcode_dataset_entry_point": "Solution().maximumSubsequenceCount",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:55",
"test... | typescript | {
"raw_signature": "function maximumSubsequenceCount(text: string, pattern: string): number {",
"container": null,
"callable": "maximumSubsequenceCount",
"parameters": [
{
"name": "text",
"type": "string"
},
{
"name": "pattern",
"type": "string"
}
],
"return_type": "n... |
2,208 | minimum-operations-to-halve-array-sum | Medium | You are given an array nums of positive integers. In one operation, you can choose any number from nums and reduce it to exactly half the number. (Note that you may choose this reduced number in future operations.)
Return the minimum number of operations to reduce the sum of nums by at least half.
Example 1:
Input: ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [100, 100, 100, 100]) == 4\n assert candidate(nums = [3, 8, 20]) == 3\n assert candidate(nums = [10000000... | [
"[5,19,8,1]",
"[3,8,20]"
] | [
"It is always optimal to halve the largest element.",
"What data structure allows for an efficient query of the maximum element?",
"Use a heap or priority queue to maintain the current elements."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().halveArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:44:57",
"tests_total": 81,
"tests_dropp... | typescript | {
"raw_signature": "function halveArray(nums: number[]): number {",
"container": null,
"callable": "halveArray",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,209 | minimum-white-tiles-after-covering-with-carpets | Hard | You are given a 0-indexed binary string floor, which represents the colors of tiles on a floor:
- floor[i] = '0' denotes that the i^th tile of the floor is colored black.
- On the other hand, floor[i] = '1' denotes that the i^th tile of the floor is colored white.
You are also given numCarpets and carpetLen. You have... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(floor = \"111100001111\",numCarpets = 4,carpetLen = 4) == 0\n assert candidate(floor = \"110011\",numCarpets = 3,carpetLen = 2) == 0\n assert candidate(floor = \"11111\",numCarpets = 2,carpetLen = 3) == 0\n assert candidate(floo... | [
"\"10110101\"\n2\n2",
"\"11111\"\n2\n3"
] | [
"Can you think of a DP solution?",
"Let DP[i][j] denote the minimum number of white tiles still visible from indices i to floor.length-1 after covering with at most j carpets.",
"The transition will be whether to put down the carpet at position i (if possible), or not."
] | {
"canonical_parameter_names": [
"floor",
"numCarpets",
"carpetLen"
],
"leetcode_dataset_entry_point": "Solution().minimumWhiteTiles",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:... | typescript | {
"raw_signature": "function minimumWhiteTiles(floor: string, numCarpets: number, carpetLen: number): number {",
"container": null,
"callable": "minimumWhiteTiles",
"parameters": [
{
"name": "floor",
"type": "string"
},
{
"name": "numCarpets",
"type": "number"
},
{
... |
2,210 | count-hills-and-valleys-in-an-array | Easy | You are given a 0-indexed integer array nums. An index i is part of a hill in nums if the closest non-equal neighbors of i are smaller than nums[i]. Similarly, an index i is part of a valley in nums if the closest non-equal neighbors of i are larger than nums[i]. Adjacent indices i and j are part of the same hill or va... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 0\n assert candidate(nums = [100, 99, 100, 98, 99, 100]) == 3\n assert candidate(nums =... | [
"[2,4,1,1,6,5]",
"[6,6,5,5,4,1]"
] | [
"For each index, could you find the closest non-equal neighbors?",
"Ensure that adjacent indices that are part of the same hill or valley are not double-counted."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countHillValley",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:01",
"tests_total": 154,
"tests... | typescript | {
"raw_signature": "function countHillValley(nums: number[]): number {",
"container": null,
"callable": "countHillValley",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
2,211 | count-collisions-on-a-road | Medium | There are n cars on an infinitely long road. The cars are numbered from 0 to n - 1 from left to right and each car is present at a unique point.
You are given a 0-indexed string directions of length n. directions[i] can be either 'L', 'R', or 'S' denoting whether the i^th car is moving towards the left, towards the ri... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(directions = \"SSRLSL\") == 3\n assert candidate(directions = \"LRLRLR\") == 4\n assert candidate(directions = \"RRRR\") == 0\n assert candidate(directions = \"LRRSLRLR\") == 5\n assert candidate(directions = \"LSRL\") == 2\n... | [
"\"RLRSLL\"",
"\"LLRR\""
] | [
"In what circumstances does a moving car not collide with another car?",
"If we disregard the moving cars that do not collide with another car, what does each moving car contribute to the answer?",
"Will stationary cars contribute towards the answer?"
] | {
"canonical_parameter_names": [
"directions"
],
"leetcode_dataset_entry_point": "Solution().countCollisions",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:04",
"tests_total": 177,
... | typescript | {
"raw_signature": "function countCollisions(directions: string): number {",
"container": null,
"callable": "countCollisions",
"parameters": [
{
"name": "directions",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
2,212 | maximum-points-in-an-archery-competition | Medium | Alice and Bob are opponents in an archery competition. The competition has set the following rules:
1. Alice first shoots numArrows arrows and then Bob shoots numArrows arrows.
2. The points are then calculated as follows:
1. The target has integer scoring sections ranging from 0 to 11 inclusive.
2. For each secti... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(numArrows = 100000,aliceArrows = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == [9991, 0, 0, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001]\n assert candidate(numArrows = 5,ali... | [
"9\n[1,1,0,1,0,0,2,1,0,1,2,0]",
"3\n[0,0,1,0,0,0,0,0,0,0,0,2]"
] | [
"To obtain points for some certain section x, what is the minimum number of arrows Bob must shoot?",
"Given the small number of sections, can we brute force which sections Bob wants to win?",
"For every set of sections Bob wants to win, check if we have the required amount of arrows. If we do, it is a valid sel... | {
"canonical_parameter_names": [
"numArrows",
"aliceArrows"
],
"leetcode_dataset_entry_point": "Solution().maximumBobPoints",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:06",
"te... | typescript | {
"raw_signature": "function maximumBobPoints(numArrows: number, aliceArrows: number[]): number[] {",
"container": null,
"callable": "maximumBobPoints",
"parameters": [
{
"name": "numArrows",
"type": "number"
},
{
"name": "aliceArrows",
"type": "number[]"
}
],
"return... |
2,213 | longest-substring-of-one-repeating-character | Hard | You are given a 0-indexed string s. You are also given a 0-indexed string queryCharacters of length k and a 0-indexed array of integer indices queryIndices of length k, both of which are used to describe k queries.
The i^th query updates the character in s at index queryIndices[i] to the character queryCharacters[i].
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abcde\",queryCharacters = \"aaaaa\",queryIndices = [0, 1, 2, 3, 4]) == [1, 2, 3, 4, 5]\n assert candidate(s = \"abyzz\",queryCharacters = \"aa\",queryIndices = [2, 1]) == [2, 3]\n assert candidate(s = \"abcde\",queryCharacter... | [
"\"babacc\"\n\"bcb\"\n[1,3,3]",
"\"abyzz\"\n\"aa\"\n[2,1]"
] | [
"Use a segment tree to perform fast point updates and range queries.",
"We need each segment tree node to store the length of the longest substring of that segment consisting of only 1 repeating character.",
"We will also have each segment tree node store the leftmost and rightmost character of the segment, the... | {
"canonical_parameter_names": [
"s",
"queryCharacters",
"queryIndices"
],
"leetcode_dataset_entry_point": "Solution().longestRepeating",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T... | typescript | {
"raw_signature": "function longestRepeating(s: string, queryCharacters: string, queryIndices: number[]): number[] {",
"container": null,
"callable": "longestRepeating",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "queryCharacters",
"type": "string"
},
... |
2,215 | find-the-difference-of-two-arrays | Easy | Given two 0-indexed integer arrays nums1 and nums2, return a list answer of size 2 where:
- answer[0] is a list of all distinct integers in nums1 which are not present in nums2.
- answer[1] is a list of all distinct integers in nums2 which are not present in nums1.
Note that the integers in the lists may be returned ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums1 = [0, -1, -2],nums2 = [1, -1, 2]) == [[0, -2], [1, 2]]\n assert candidate(nums1 = [5, 7, 8],nums2 = [9, 10, 5]) == [[8, 7], [9, 10]]\n assert candidate(nums1 = [10, 20, 30],nums2 = [5, 15, 25, 35]) == [[10, 20, 30], [25, 35, ... | [
"[1,2,3]\n[2,4,6]",
"[1,2,3,3]\n[1,1,2,2]"
] | [
"For each integer in nums1, check if it exists in nums2.",
"Do the same for each integer in nums2."
] | {
"canonical_parameter_names": [
"nums1",
"nums2"
],
"leetcode_dataset_entry_point": "Solution().findDifference",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:13",
"tests_total": ... | typescript | {
"raw_signature": "function findDifference(nums1: number[], nums2: number[]): number[][] {",
"container": null,
"callable": "findDifference",
"parameters": [
{
"name": "nums1",
"type": "number[]"
},
{
"name": "nums2",
"type": "number[]"
}
],
"return_type": "number[][... |
2,216 | minimum-deletions-to-make-array-beautiful | Medium | You are given a 0-indexed integer array nums. The array nums is beautiful if:
- nums.length is even.
- nums[i] != nums[i + 1] for all i % 2 == 0.
Note that an empty array is considered beautiful.
You can delete any number of elements from nums. When you delete an element, all the elements to the right of the deleted... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000]) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3]) == 2\n assert candidate(nums = [100000, 100000, 99999, 99999, 99998, 99998]) == 2\n ... | [
"[1,1,2,3,5]",
"[1,1,2,2,3,3]"
] | [
"Delete as many adjacent equal elements as necessary.",
"If the length of nums is odd after the entire process, delete the last element."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().minDeletion",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:15",
"tests_total": 125,
"tests_dro... | typescript | {
"raw_signature": "function minDeletion(nums: number[]): number {",
"container": null,
"callable": "minDeletion",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,217 | find-palindrome-with-fixed-length | Medium | Given an integer array queries and a positive integer intLength, return an array answer where answer[i] is either the queries[i]^th smallest positive palindrome of length intLength or -1 if no such palindrome exists.
A palindrome is a number that reads the same backwards and forwards. Palindromes cannot have leading z... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(queries = [10, 20, 30],intLength = 2) == [-1, -1, -1]\n assert candidate(queries = [1, 3, 5, 7, 9],intLength = 5) == [10001, 10201, 10401, 10601, 10801]\n assert candidate(queries = [50000],intLength = 15) == [100499999994001]\n ... | [
"[1,2,3,4,5,90]\n3",
"[2,4,6]\n4"
] | [
"For any value of queries[i] and intLength, how can you check if there exists at least queries[i] palindromes of length intLength?",
"Since a palindrome reads the same forwards and backwards, consider how you can efficiently find the first half (ceil(intLength/2) digits) of the palindrome."
] | {
"canonical_parameter_names": [
"queries",
"intLength"
],
"leetcode_dataset_entry_point": "Solution().kthPalindrome",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:18",
"tests_tot... | typescript | {
"raw_signature": "function kthPalindrome(queries: number[], intLength: number): number[] {",
"container": null,
"callable": "kthPalindrome",
"parameters": [
{
"name": "queries",
"type": "number[]"
},
{
"name": "intLength",
"type": "number"
}
],
"return_type": "numbe... |
2,218 | maximum-value-of-k-coins-from-piles | Hard | There are n piles of coins on a table. Each pile consists of a positive number of coins of assorted denominations.
In one move, you can choose any coin on top of any pile, remove it, and add it to your wallet.
Given a list piles, where piles[i] is a list of integers denoting the composition of the i^th pile from top ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(piles = [[30, 10], [50, 20, 10]],k = 3) == 100\n assert candidate(piles = [[1, 2], [3, 4], [5, 6]],k = 5) == 19\n assert candidate(piles = [[10, 20], [5, 5, 5, 5], [1, 1, 1, 1, 1]],k = 5) == 45\n assert candidate(piles = [[1, 2,... | [
"[[1,100,3],[7,8,9]]\n2",
"[[100],[100],[100],[100],[100],[100],[1,1,1,1,1,1,700]]\n7"
] | [
"For each pile i, what will be the total value of coins we can collect if we choose the first j coins?",
"How can we use dynamic programming to combine the results from different piles to find the most optimal answer?"
] | {
"canonical_parameter_names": [
"piles",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxValueOfCoins",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:20",
"tests_total": 96,... | typescript | {
"raw_signature": "function maxValueOfCoins(piles: number[][], k: number): number {",
"container": null,
"callable": "maxValueOfCoins",
"parameters": [
{
"name": "piles",
"type": "number[][]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signatu... |
2,220 | minimum-bit-flips-to-convert-number | Easy | A bit flip of a number x is choosing a bit in the binary representation of x and flipping it from either 0 to 1 or 1 to 0.
- For example, for x = 7, the binary representation is 111 and we may choose any bit (including any leading zeros not shown) and flip it. We can flip the first bit from the right to get 110, flip ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(start = 123456789,goal = 987654321) == 15\n assert candidate(start = 5,goal = 2) == 3\n assert candidate(start = 1000000000,goal = 500000000) == 14\n assert candidate(start = 8,goal = 15) == 3\n assert candidate(start = 15,go... | [
"10\n7",
"3\n4"
] | [
"If the value of a bit in start and goal differ, then we need to flip that bit.",
"Consider using the XOR operation to determine which bits need a bit flip."
] | {
"canonical_parameter_names": [
"start",
"goal"
],
"leetcode_dataset_entry_point": "Solution().minBitFlips",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:25",
"tests_total": 85,
... | typescript | {
"raw_signature": "function minBitFlips(start: number, goal: number): number {",
"container": null,
"callable": "minBitFlips",
"parameters": [
{
"name": "start",
"type": "number"
},
{
"name": "goal",
"type": "number"
}
],
"return_type": "number",
"signature_source"... |
2,221 | find-triangular-sum-of-an-array | Medium | You are given a 0-indexed integer array nums, where nums[i] is a digit between 0 and 9 (inclusive).
The triangular sum of nums is the value of the only element present in nums after the following process terminates:
1. Let nums comprise of n elements. If n == 1, end the process. Otherwise, create a new 0-indexed inte... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 6\n assert candidate(nums = [4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 2]) == 3\n assert candidate(nums = [1, 2, 3... | [
"[1,2,3,4,5]",
"[5]"
] | [
"Try simulating the entire process.",
"To reduce space, use a temporary array to update nums in every step instead of creating a new array at each step."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().triangularSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:27",
"tests_total": 96,
"tests_dr... | typescript | {
"raw_signature": "function triangularSum(nums: number[]): number {",
"container": null,
"callable": "triangularSum",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
2,222 | number-of-ways-to-select-buildings | Medium | You are given a 0-indexed binary string s which represents the types of buildings along a street where:
- s[i] = '0' denotes that the i^th building is an office and
- s[i] = '1' denotes that the i^th building is a restaurant.
As a city official, you would like to select 3 buildings for random inspection. However, to ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"100100100\") == 24\n assert candidate(s = \"101010101\") == 30\n assert candidate(s = \"000111000\") == 27\n assert candidate(s = \"111\") == 0\n assert candidate(s = \"0000000001\") == 0\n assert candidate(s = \"010... | [
"\"001101\"",
"\"11100\""
] | [
"There are only 2 valid patterns: ‘101’ and ‘010’. Think about how we can construct these 2 patterns from smaller patterns.",
"Count the number of subsequences of the form ‘01’ or ‘10’ first. Let n01[i] be the number of ‘01’ subsequences that exist in the prefix of s up to the ith building. How can you compute n0... | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().numberOfWays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:29",
"tests_total": 162,
"tests_dropp... | typescript | {
"raw_signature": "function numberOfWays(s: string): number {",
"container": null,
"callable": "numberOfWays",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,223 | sum-of-scores-of-built-strings | Hard | You are building a string s of length n one character at a time, prepending each new character to the front of the string. The strings are labeled from 1 to n, where the string with length i is labeled s_i.
- For example, for s = "abaca", s_1 == "a", s_2 == "ca", s_3 == "aca", etc.
The score of s_i is the length of t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"xyzxyzxyz\") == 18\n assert candidate(s = \"abcabcabc\") == 18\n assert candidate(s = \"aabbcc\") == 7\n assert candidate(s = \"abacabadabacaba\") == 32\n assert candidate(s = \"zzzzz\") == 15\n assert candidate(s = ... | [
"\"babab\"",
"\"azbazbzaz\""
] | [
"Each s_i is a suffix of the string s, so consider algorithms that can determine the longest prefix that is also a suffix.",
"Could you use the Z array from the Z algorithm to find the score of each s_i?"
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().sumScores",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:32",
"tests_total": 123,
"tests_dropped"... | typescript | {
"raw_signature": "function sumScores(s: string): number {",
"container": null,
"callable": "sumScores",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,224 | minimum-number-of-operations-to-convert-time | Easy | You are given two strings current and correct representing two 24-hour times.
24-hour times are formatted as "HH:MM", where HH is between 00 and 23, and MM is between 00 and 59. The earliest 24-hour time is 00:00, and the latest is 23:59.
In one operation you can increase the time current by 1, 5, 15, or 60 minutes. ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(current = \"01:59\",correct = \"02:00\") == 1\n assert candidate(current = \"00:01\",correct = \"00:02\") == 1\n assert candidate(current = \"02:30\",correct = \"04:35\") == 3\n assert candidate(current = \"12:00\",correct = \"1... | [
"\"02:30\"\n\"04:35\"",
"\"11:00\"\n\"11:01\""
] | [
"Convert the times to minutes.",
"Use the operation with the biggest value possible at each step."
] | {
"canonical_parameter_names": [
"current",
"correct"
],
"leetcode_dataset_entry_point": "Solution().convertTime",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:34",
"tests_total":... | typescript | {
"raw_signature": "function convertTime(current: string, correct: string): number {",
"container": null,
"callable": "convertTime",
"parameters": [
{
"name": "current",
"type": "string"
},
{
"name": "correct",
"type": "string"
}
],
"return_type": "number",
"signatu... |
2,225 | find-players-with-zero-or-one-losses | Medium | You are given an integer array matches where matches[i] = [winner_i, loser_i] indicates that the player winner_i defeated player loser_i in a match.
Return a list answer of size 2 where:
- answer[0] is a list of all players that have not lost any matches.
- answer[1] is a list of all players that have lost exactly on... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(matches = [[1, 2]]) == [[1], [2]]\n assert candidate(matches = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == [[], [1, 2, 3, 4, 5]]\n assert candidate(matches = [[100, 200], [200, 300], [100, 300], [400, 500]]) == [[100, 400], [200, ... | [
"[[1,3],[2,3],[3,6],[5,6],[5,7],[4,5],[4,8],[4,9],[10,4],[10,9]]",
"[[2,3],[1,3],[5,4],[6,4]]"
] | [
"Count the number of times a player loses while iterating through the matches."
] | {
"canonical_parameter_names": [
"matches"
],
"leetcode_dataset_entry_point": "Solution().findWinners",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:36",
"tests_total": 69,
"tests_d... | typescript | {
"raw_signature": "function findWinners(matches: number[][]): number[][] {",
"container": null,
"callable": "findWinners",
"parameters": [
{
"name": "matches",
"type": "number[][]"
}
],
"return_type": "number[][]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcod... |
2,226 | maximum-candies-allocated-to-k-children | Medium | You are given a 0-indexed integer array candies. Each element in the array denotes a pile of candies of size candies[i]. You can divide each pile into any number of sub piles, but you cannot merge two piles together.
You are also given an integer k. You should allocate piles of candies to k children such that each chi... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(candies = [10000000, 10000000, 10000000],k = 10000000) == 2\n assert candidate(candies = [7, 14, 10, 7],k = 3) == 7\n assert candidate(candies = [5, 8, 6],k = 3) == 5\n assert candidate(candies = [3, 9, 7],k = 6) == 3\n asser... | [
"[5,8,6]\n3",
"[2,5]\n11"
] | [
"For a fixed number of candies c, how can you check if each child can get c candies?",
"Use binary search to find the maximum c as the answer."
] | {
"canonical_parameter_names": [
"candies",
"k"
],
"leetcode_dataset_entry_point": "Solution().maximumCandies",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:39",
"tests_total": 82... | typescript | {
"raw_signature": "function maximumCandies(candies: number[], k: number): number {",
"container": null,
"callable": "maximumCandies",
"parameters": [
{
"name": "candies",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature... |
2,231 | largest-number-after-digit-swaps-by-parity | Easy | You are given a positive integer num. You may swap any two digits of num that have the same parity (i.e. both odd digits or both even digits).
Return the largest possible value of num after any number of swaps.
Example 1:
Input: num = 1234
Output: 3412
Explanation: Swap the digit 3 with the digit 1, this results in ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = 24680) == 86420\n assert candidate(num = 987654321) == 987654321\n assert candidate(num = 13524687) == 75386421\n assert candidate(num = 1000000) == 1000000\n assert candidate(num = 2222) == 2222\n assert candidate(n... | [
"1234",
"65875"
] | [
"The bigger digit should appear first (more to the left) because it contributes more to the value of the number.",
"Get all the even digits, as well as odd digits. Sort them separately.",
"Reconstruct the number by giving the earlier digits the highest available digit of the same parity."
] | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().largestInteger",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:43",
"tests_total": 78,
"tests_dr... | typescript | {
"raw_signature": "function largestInteger(num: number): number {",
"container": null,
"callable": "largestInteger",
"parameters": [
{
"name": "num",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,232 | minimize-result-by-adding-parentheses-to-expression | Medium | You are given a 0-indexed string expression of the form "<num1>+<num2>" where <num1> and <num2> represent positive integers.
Add a pair of parentheses to expression such that after the addition of parentheses, expression is a valid mathematical expression and evaluates to the smallest possible value. The left parenthe... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(expression = \"56+78\") == \"(56+78)\"\n assert candidate(expression = \"5+6\") == \"(5+6)\"\n assert candidate(expression = \"3+8\") == \"(3+8)\"\n assert candidate(expression = \"111+222\") == \"1(11+22)2\"\n assert candida... | [
"\"247+38\"",
"\"12+34\"",
"\"999+999\""
] | [
"The maximum length of expression is very low. We can try every possible spot to place the parentheses.",
"Every possibility of expression is of the form a * (b + c) * d where a, b, c, d represent integers. Note the edge cases where a and/or d do not exist, in which case use 1 instead of them."
] | {
"canonical_parameter_names": [
"expression"
],
"leetcode_dataset_entry_point": "Solution().minimizeResult",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:46",
"tests_total": 134,
"... | typescript | {
"raw_signature": "function minimizeResult(expression: string): string {",
"container": null,
"callable": "minimizeResult",
"parameters": [
{
"name": "expression",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
2,233 | maximum-product-after-k-increments | Medium | You are given an array of non-negative integers nums and an integer k. In one operation, you may choose any element from nums and increment it by 1.
Return the maximum product of nums after at most k operations. Since the answer may be very large, return it modulo 10^9 + 7. Note that you should maximize the product be... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 7776\n assert candidate(nums = [1, 2, 3, 4],k = 3) == 108\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 94500000\n assert candidate(nums = [0, 4],k = 5) == 20\n assert c... | [
"[0,4]\n5",
"[6,3,3,2]\n2"
] | [
"If you can increment only once, which number should you increment?",
"We should always prioritize the smallest number. What kind of data structure could we use?",
"Use a min heap to hold all the numbers. Each time we do an operation, replace the top of the heap x by x + 1."
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().maximumProduct",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:48",
"tests_total": 101,
... | typescript | {
"raw_signature": "function maximumProduct(nums: number[], k: number): number {",
"container": null,
"callable": "maximumProduct",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_sourc... |
2,234 | maximum-total-beauty-of-the-gardens | Hard | Alice is a caretaker of n gardens and she wants to plant flowers to maximize the total beauty of all her gardens.
You are given a 0-indexed integer array flowers of size n, where flowers[i] is the number of flowers already planted in the i^th garden. Flowers that are already planted cannot be removed. You are then giv... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(flowers = [10, 20, 30, 40, 50],newFlowers = 100,target = 25,full = 5,partial = 2) == 68\n assert candidate(flowers = [1, 1, 1, 1],newFlowers = 15,target = 3,full = 5,partial = 3) == 21\n assert candidate(flowers = [5, 5, 5, 5],newF... | [
"[1,3,1,1]\n7\n6\n12\n1",
"[2,4,5,3]\n10\n5\n2\n6"
] | [
"Say we choose k gardens to be complete, is there an optimal way of choosing which gardens to plant more flowers to achieve this?",
"For a given k, we should greedily fill-up the k gardens with the most flowers planted already. This gives us the most remaining flowers to fill up the other gardens.",
"After sort... | {
"canonical_parameter_names": [
"flowers",
"newFlowers",
"target",
"full",
"partial"
],
"leetcode_dataset_entry_point": "Solution().maximumBeauty",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetche... | typescript | {
"raw_signature": "function maximumBeauty(flowers: number[], newFlowers: number, target: number, full: number, partial: number): number {",
"container": null,
"callable": "maximumBeauty",
"parameters": [
{
"name": "flowers",
"type": "number[]"
},
{
"name": "newFlowers",
"typ... |
2,235 | add-two-integers | Easy | Given two integers num1 and num2, return the sum of the two integers.
Example 1:
Input: num1 = 12, num2 = 5
Output: 17
Explanation: num1 is 12, num2 is 5, and their sum is 12 + 5 = 17, so 17 is returned.
Example 2:
Input: num1 = -10, num2 = 4
Output: -6
Explanation: num1 + num2 = -6, so -6 is returned.
Constraints... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num1 = 100,num2 = -100) == 0\n assert candidate(num1 = -10,num2 = 4) == -6\n assert candidate(num1 = 25,num2 = 25) == 50\n assert candidate(num1 = -50,num2 = 50) == 0\n assert candidate(num1 = 99,num2 = 1) == 100\n assert ... | [
"12\n5",
"-10\n4"
] | [] | {
"canonical_parameter_names": [
"num1",
"num2"
],
"leetcode_dataset_entry_point": "Solution().sum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:53",
"tests_total": 59,
"tests_... | typescript | {
"raw_signature": "function sum(num1: number, num2: number): number {",
"container": null,
"callable": "sum",
"parameters": [
{
"name": "num1",
"type": "number"
},
{
"name": "num2",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSn... |
2,239 | find-closest-number-to-zero | Easy | Given an integer array nums of size n, return the number with the value closest to 0 in nums. If there are multiple answers, return the number with the largest value.
Example 1:
Input: nums = [-4,-2,1,4,8]
Output: 1
Explanation:
The distance from -4 to 0 is |-4| = 4.
The distance from -2 to 0 is |-2| = 2.
The distanc... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [3, -3, 2, -2, 1, -1]) == 1\n assert candidate(nums = [100000, -100000, 50000, -50000]) == 50000\n assert candidate(nums = [100000, -100000, 50000, -50000]) == 50000\n assert candidate(nums = [7, -10, 4, 3, -20, 2]) == 2\... | [
"[-4,-2,1,4,8]",
"[2,-1,1]"
] | [
"Keep track of the number closest to 0 as you iterate through the array.",
"Ensure that if multiple numbers are closest to 0, you store the one with the largest value."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().findClosestNumber",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:45:59",
"tests_total": 128,
"tes... | typescript | {
"raw_signature": "function findClosestNumber(nums: number[]): number {",
"container": null,
"callable": "findClosestNumber",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
2,240 | number-of-ways-to-buy-pens-and-pencils | Medium | You are given an integer total indicating the amount of money you have. You are also given two integers cost1 and cost2 indicating the price of a pen and pencil respectively. You can spend part or all of your money to buy multiple quantities (or none) of each kind of writing utensil.
Return the number of distinct ways... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(total = 20,cost1 = 10,cost2 = 5) == 9\n assert candidate(total = 1000,cost1 = 1,cost2 = 1) == 501501\n assert candidate(total = 5,cost1 = 10,cost2 = 10) == 1\n assert candidate(total = 5,cost1 = 10,cost2 = 10) == 1\n assert c... | [
"20\n10\n5",
"5\n10\n10"
] | [
"Fix the number of pencils purchased and calculate the number of ways to buy pens.",
"Sum up the number of ways to buy pens for each amount of pencils purchased to get the answer."
] | {
"canonical_parameter_names": [
"total",
"cost1",
"cost2"
],
"leetcode_dataset_entry_point": "Solution().waysToBuyPensPencils",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:01"... | typescript | {
"raw_signature": "function waysToBuyPensPencils(total: number, cost1: number, cost2: number): number {",
"container": null,
"callable": "waysToBuyPensPencils",
"parameters": [
{
"name": "total",
"type": "number"
},
{
"name": "cost1",
"type": "number"
},
{
"nam... |
2,242 | maximum-score-of-a-node-sequence | Hard | There is an undirected graph with n nodes, numbered from 0 to n - 1.
You are given a 0-indexed integer array scores of length n where scores[i] denotes the score of node i. You are also given a 2D integer array edges where edges[i] = [a_i, b_i] denotes that there exists an undirected edge connecting nodes a_i and b_i.... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(scores = [5, 2, 9, 8, 4],edges = [[0, 1], [1, 2], [2, 3], [0, 2], [1, 3], [2, 4]]) == 24\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 4\n assert candidate... | [
"[5,2,9,8,4]\n[[0,1],[1,2],[2,3],[0,2],[1,3],[2,4]]",
"[9,20,6,4,11,12]\n[[0,3],[5,3],[2,4],[1,3]]"
] | [
"For every node sequence of length 4, there are 3 relevant edges. How can we consider valid triplets of edges?",
"Fix the middle 2 nodes connected by an edge in the node sequence. Can you determine the other 2 nodes that will give the highest possible score?",
"The other 2 nodes must each be connected to one of... | {
"canonical_parameter_names": [
"scores",
"edges"
],
"leetcode_dataset_entry_point": "Solution().maximumScore",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:04",
"tests_total": 8... | typescript | {
"raw_signature": "function maximumScore(scores: number[], edges: number[][]): number {",
"container": null,
"callable": "maximumScore",
"parameters": [
{
"name": "scores",
"type": "number[]"
},
{
"name": "edges",
"type": "number[][]"
}
],
"return_type": "number",
... |
2,243 | calculate-digit-sum-of-a-string | Easy | You are given a string s consisting of digits and an integer k.
A round can be completed if the length of s is greater than k. In one round, do the following:
1. Divide s into consecutive groups of size k such that the first k characters are in the first group, the next k characters are in the second group, and so on... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"00000000\",k = 3) == \"000\"\n assert candidate(s = \"111\",k = 5) == \"111\"\n assert candidate(s = \"987654321\",k = 2) == \"36\"\n assert candidate(s = \"11111222223\",k = 3) == \"135\"\n assert candidate(s = \"98765... | [
"\"11111222223\"\n3",
"\"00000000\"\n3"
] | [
"Try simulating the entire process to find the final answer."
] | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().digitSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:06",
"tests_total": 109,
"tests_... | typescript | {
"raw_signature": "function digitSum(s: string, k: number): string {",
"container": null,
"callable": "digitSum",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnip... |
2,244 | minimum-rounds-to-complete-all-tasks | Medium | You are given a 0-indexed integer array tasks, where tasks[i] represents the difficulty level of a task. In each round, you can complete either 2 or 3 tasks of the same difficulty level.
Return the minimum rounds required to complete all the tasks, or -1 if it is not possible to complete all the tasks.
Example 1:
In... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(tasks = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 5\n assert candidate(tasks = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 5\n assert candidate(tasks = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 7\n ... | [
"[2,2,3,3,2,4,4,4,4,4]",
"[2,3,3]"
] | [
"Which data structure can you use to store the number of tasks of each difficulty level?",
"For any particular difficulty level, what can be the optimal strategy to complete the tasks using minimum rounds?",
"When can we not complete all tasks of a difficulty level?"
] | {
"canonical_parameter_names": [
"tasks"
],
"leetcode_dataset_entry_point": "Solution().minimumRounds",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:09",
"tests_total": 58,
"tests_d... | typescript | {
"raw_signature": "function minimumRounds(tasks: number[]): number {",
"container": null,
"callable": "minimumRounds",
"parameters": [
{
"name": "tasks",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
2,245 | maximum-trailing-zeros-in-a-cornered-path | Medium | You are given a 2D integer array grid of size m x n, where each cell contains a positive integer.
A cornered path is defined as a set of adjacent cells with at most one turn. More specifically, the path should exclusively move either horizontally or vertically up to the turn (if there is one), without returning to a p... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == 0\n assert candidate(grid = [[5, 10, 15], [20, 25, 30], [35, 40, 45]]) == 5\n assert candidate(grid = [[2, 4, 6, 8], [10, 20, 30, 40], [50, 60, 70, 80]]) == 6\n assert candid... | [
"[[23,17,15,3,20],[8,1,20,27,11],[9,4,6,2,21],[40,9,1,10,6],[22,7,4,5,3]]",
"[[4,3,2],[7,6,1],[8,8,8]]"
] | [
"What actually tells us the trailing zeros of the product of a path?",
"It is the sum of the exponents of 2 and sum of the exponents of 5 of the prime factorizations of the numbers on that path. The smaller of the two is the answer for that path.",
"We can then treat each cell as the elbow point and calculate t... | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().maxTrailingZeros",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:11",
"tests_total": 84,
"tests... | typescript | {
"raw_signature": "function maxTrailingZeros(grid: number[][]): number {",
"container": null,
"callable": "maxTrailingZeros",
"parameters": [
{
"name": "grid",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
2,246 | longest-path-with-different-adjacent-characters | Hard | You are given a tree (i.e. a connected, undirected graph that has no cycles) rooted at node 0 consisting of n nodes numbered from 0 to n - 1. The tree is represented by a 0-indexed array parent of size n, where parent[i] is the parent of node i. Since node 0 is the root, parent[0] == -1.
You are also given a string s ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(parent = [-1, 0, 0, 2, 2, 2],s = \"abbccc\") == 4\n assert candidate(parent = [-1, 0, 0, 0],s = \"aabc\") == 3\n assert candidate(parent = [-1, 0, 0, 1, 1, 2],s = \"abacbe\") == 3\n assert candidate(parent = [-1, 0, 1, 2, 3, 4, ... | [
"[-1,0,0,1,1,2]\n\"abacbe\"",
"[-1,0,0,0]\n\"aabc\""
] | [
"Do a DFS from the root. At each node, calculate the longest path we can make from two branches of that subtree.",
"To do that, we need to find the length of the longest path from each of the node’s children."
] | {
"canonical_parameter_names": [
"parent",
"s"
],
"leetcode_dataset_entry_point": "Solution().longestPath",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:14",
"tests_total": 49,
... | typescript | {
"raw_signature": "function longestPath(parent: number[], s: string): number {",
"container": null,
"callable": "longestPath",
"parameters": [
{
"name": "parent",
"type": "number[]"
},
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source"... |
2,248 | intersection-of-multiple-arrays | Easy | Given a 2D integer array nums where nums[i] is a non-empty array of distinct positive integers, return the list of integers that are present in each array of nums sorted in ascending order.
Example 1:
Input: nums = [[3,1,2,4,5],[1,2,3,4],[3,4,5,6]]
Output: [3,4]
Explanation:
The only integers present in each of nums[... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [30, 60, 70]]) == [30]\n assert candidate(nums = [[3, 1, 2, 4, 5], [1, 2, 3, 4], [3, 4, 5, 6]]) == [3, 4]\n assert candidate(nums = [[10, 20, 30], [20, 30, 40], [30, 40, 50]]) == [3... | [
"[[3,1,2,4,5],[1,2,3,4],[3,4,5,6]]",
"[[1,2,3],[4,5,6]]"
] | [
"Keep a count of the number of times each integer occurs in nums.",
"Since all integers of nums[i] are distinct, if an integer is present in each array, its count will be equal to the total number of arrays."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().intersection",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:18",
"tests_total": 93,
"tests_dro... | typescript | {
"raw_signature": "function intersection(nums: number[][]): number[] {",
"container": null,
"callable": "intersection",
"parameters": [
{
"name": "nums",
"type": "number[][]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
2,249 | count-lattice-points-inside-a-circle | Medium | Given a 2D integer array circles where circles[i] = [x_i, y_i, r_i] represents the center (x_i, y_i) and radius r_i of the i^th circle drawn on a grid, return the number of lattice points that are present inside at least one circle.
Note:
- A lattice point is a point with integer coordinates.
- Points that lie on the... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(circles = [[1, 1, 1], [2, 2, 2], [3, 3, 3]]) == 33\n assert candidate(circles = [[10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5]]) == 276\n assert candidate(circles = [[2, 2, 1]]) == 5\n assert candidate(circles = [[10, 10, 5... | [
"[[2,2,1]]",
"[[2,2,2],[3,4,1]]"
] | [
"For each circle, how can you check whether or not a lattice point lies inside it?",
"Since you need to reduce the search space, consider the minimum and maximum possible values of the coordinates of a lattice point contained in any circle."
] | {
"canonical_parameter_names": [
"circles"
],
"leetcode_dataset_entry_point": "Solution().countLatticePoints",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:21",
"tests_total": 114,
... | typescript | {
"raw_signature": "function countLatticePoints(circles: number[][]): number {",
"container": null,
"callable": "countLatticePoints",
"parameters": [
{
"name": "circles",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "l... |
2,250 | count-number-of-rectangles-containing-each-point | Medium | You are given a 2D integer array rectangles where rectangles[i] = [l_i, h_i] indicates that i^th rectangle has a length of l_i and a height of h_i. You are also given a 2D integer array points where points[j] = [x_j, y_j] is a point with coordinates (x_j, y_j).
The i^th rectangle has its bottom-left corner point at th... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(rectangles = [[1, 2], [2, 3], [2, 5]],points = [[2, 1], [1, 4]]) == [2, 1]\n assert candidate(rectangles = [[10, 100], [9, 99], [8, 98], [7, 97]],points = [[10, 100], [9, 99], [8, 98], [7, 97]]) == [1, 2, 3, 4]\n assert candidate(r... | [
"[[1,2],[2,3],[2,5]]\n[[2,1],[1,4]]",
"[[1,1],[2,2],[3,3]]\n[[1,3],[1,1]]"
] | [
"The heights of the rectangles and the y-coordinates of the points are only at most 100, so for each point, we can iterate over the possible heights of the rectangles that contain a given point.",
"For a given point and height, can we efficiently count how many rectangles with that height contain our point?",
"... | {
"canonical_parameter_names": [
"rectangles",
"points"
],
"leetcode_dataset_entry_point": "Solution().countRectangles",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:23",
"tests_t... | typescript | {
"raw_signature": "function countRectangles(rectangles: number[][], points: number[][]): number[] {",
"container": null,
"callable": "countRectangles",
"parameters": [
{
"name": "rectangles",
"type": "number[][]"
},
{
"name": "points",
"type": "number[][]"
}
],
"retu... |
2,251 | number-of-flowers-in-full-bloom | Hard | You are given a 0-indexed 2D integer array flowers, where flowers[i] = [start_i, end_i] means the i^th flower will be in full bloom from start_i to end_i (inclusive). You are also given a 0-indexed integer array people of size n, where people[i] is the time that the i^th person will arrive to see the flowers.
Return a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(flowers = [[1, 10], [3, 3]],people = [3, 3, 2]) == [2, 2, 1]\n assert candidate(flowers = [[1, 100]],people = [50, 100, 150]) == [1, 1, 0]\n assert candidate(flowers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],people = [1, 2, 3, 4,... | [
"[[1,6],[3,7],[9,12],[4,13]]\n[2,3,7,11]",
"[[1,10],[3,3]]\n[3,3,2]"
] | [
"Notice that for any given time t, the number of flowers blooming at time t is equal to the number of flowers that have started blooming minus the number of flowers that have already stopped blooming.",
"We can obtain these values efficiently using binary search.",
"We can store the starting times in sorted ord... | {
"canonical_parameter_names": [
"flowers",
"people"
],
"leetcode_dataset_entry_point": "Solution().fullBloomFlowers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:26",
"tests_tot... | typescript | {
"raw_signature": "function fullBloomFlowers(flowers: number[][], people: number[]): number[] {",
"container": null,
"callable": "fullBloomFlowers",
"parameters": [
{
"name": "flowers",
"type": "number[][]"
},
{
"name": "people",
"type": "number[]"
}
],
"return_type"... |
2,255 | count-prefixes-of-a-given-string | Easy | You are given a string array words and a string s, where words[i] and s comprise only of lowercase English letters.
Return the number of strings in words that are a prefix of s.
A prefix of a string is a substring that occurs at the beginning of the string. A substring is a contiguous sequence of characters within a ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(words = ['hello', 'hell', 'he', 'h'],s = \"hello\") == 4\n assert candidate(words = ['short'],s = \"shorter\") == 1\n assert candidate(words = ['same', 'same'],s = \"same\") == 2\n assert candidate(words = ['hello'],s = \"h\") =... | [
"[\"a\",\"b\",\"c\",\"ab\",\"bc\",\"abc\"]\n\"abc\"",
"[\"a\",\"a\"]\n\"aa\""
] | [
"For each string in words, check if it is a prefix of s. If true, increment the answer by 1."
] | {
"canonical_parameter_names": [
"words",
"s"
],
"leetcode_dataset_entry_point": "Solution().countPrefixes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:28",
"tests_total": 146,
... | typescript | {
"raw_signature": "function countPrefixes(words: string[], s: string): number {",
"container": null,
"callable": "countPrefixes",
"parameters": [
{
"name": "words",
"type": "string[]"
},
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_sourc... |
2,256 | minimum-average-difference | Medium | You are given a 0-indexed integer array nums of length n.
The average difference of the index i is the absolute difference between the average of the first i + 1 elements of nums and the average of the last n - i - 1 elements. Both averages should be rounded down to the nearest integer.
Return the index with the mini... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 0, 1, 0, 1]) == 1\n assert candidate(nums = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0]) == 1\n assert candidate(nums = [100000, 0, 0, 0, 0, 0... | [
"[2,5,3,9,5,3]",
"[0]"
] | [
"How can we use precalculation to efficiently calculate the average difference at an index?",
"Create a prefix and/or suffix sum array."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().minimumAverageDifference",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:30",
"tests_total": 94,
... | typescript | {
"raw_signature": "function minimumAverageDifference(nums: number[]): number {",
"container": null,
"callable": "minimumAverageDifference",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": ... |
2,257 | count-unguarded-cells-in-the-grid | Medium | You are given two integers m and n representing a 0-indexed m x n grid. You are also given two 2D integer arrays guards and walls where guards[i] = [row_i, col_i] and walls[j] = [row_j, col_j] represent the positions of the i^th guard and j^th wall respectively.
A guard can see every cell in the four cardinal directio... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(m = 4,n = 6,guards = [[0, 0], [1, 1], [2, 3]],walls = [[0, 1], [2, 2], [1, 4]]) == 7\n assert candidate(m = 3,n = 3,guards = [[1, 1]],walls = [[0, 1], [1, 0], [2, 1], [1, 2]]) == 4\n assert candidate(m = 5,n = 5,guards = [[2, 2]],w... | [
"4\n6\n[[0,0],[1,1],[2,3]]\n[[0,1],[2,2],[1,4]]",
"3\n3\n[[1,1]]\n[[0,1],[1,0],[2,1],[1,2]]"
] | [
"Create a 2D array to represent the grid. Can you mark the tiles that can be seen by a guard?",
"Iterate over the guards, and for each of the 4 directions, advance the current tile and mark the tile. When should you stop advancing?"
] | {
"canonical_parameter_names": [
"m",
"n",
"guards",
"walls"
],
"leetcode_dataset_entry_point": "Solution().countUnguarded",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:33"... | typescript | {
"raw_signature": "function countUnguarded(m: number, n: number, guards: number[][], walls: number[][]): number {",
"container": null,
"callable": "countUnguarded",
"parameters": [
{
"name": "m",
"type": "number"
},
{
"name": "n",
"type": "number"
},
{
"name": ... |
2,258 | escape-the-spreading-fire | Hard | You are given a 0-indexed 2D integer array grid of size m x n which represents a field. Each cell has one of three values:
- 0 represents grass,
- 1 represents fire,
- 2 represents a wall that you and fire cannot pass through.
You are situated in the top-left cell, (0, 0), and you want to travel to the safehouse at t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 2, 0], [0, 2, 0, 0]]) == -1\n assert candidate(grid = [[0, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 1, 0, 0, 0], [0, 0, 0, 2... | [
"[[0,2,0,0,0,0,0],[0,0,0,2,2,1,0],[0,2,0,0,1,2,0],[0,0,2,2,2,0,2],[0,0,0,0,0,0,0]]",
"[[0,0,0,0],[0,1,2,0],[0,2,0,0]]",
"[[0,0,0],[2,2,0],[1,2,0]]"
] | [
"For some tile (x, y), how can we determine when, if ever, the fire will reach it?",
"We can use multi-source BFS to find the earliest time the fire will reach each cell.",
"Then, starting with a given t minutes of staying in the initial position, we can check if there is a safe path to the safehouse using the ... | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().maximumMinutes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:35",
"tests_total": 85,
"tests_d... | typescript | {
"raw_signature": "function maximumMinutes(grid: number[][]): number {",
"container": null,
"callable": "maximumMinutes",
"parameters": [
{
"name": "grid",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
2,259 | remove-digit-from-number-to-maximize-result | Easy | You are given a string number representing a positive integer and a character digit.
Return the resulting string after removing exactly one occurrence of digit from number such that the value of the resulting string in decimal form is maximized. The test cases are generated such that digit occurs at least once in numb... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(number = \"222333\",digit = \"2\") == \"22333\"\n assert candidate(number = \"99999\",digit = \"9\") == \"9999\"\n assert candidate(number = \"999\",digit = \"9\") == \"99\"\n assert candidate(number = \"551\",digit = \"5\") == ... | [
"\"123\"\n\"3\"",
"\"1231\"\n\"1\"",
"\"551\"\n\"5\""
] | [
"The maximum length of number is really small.",
"Iterate through the digits of number and every time we see digit, try removing it.",
"To remove a character at index i, concatenate the substring from index 0 to i - 1 and the substring from index i + 1 to number.length - 1."
] | {
"canonical_parameter_names": [
"number",
"digit"
],
"leetcode_dataset_entry_point": "Solution().removeDigit",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:37",
"tests_total": 12... | typescript | {
"raw_signature": "function removeDigit(number: string, digit: string): string {",
"container": null,
"callable": "removeDigit",
"parameters": [
{
"name": "number",
"type": "string"
},
{
"name": "digit",
"type": "string"
}
],
"return_type": "string",
"signature_sou... |
2,260 | minimum-consecutive-cards-to-pick-up | Medium | You are given an integer array cards where cards[i] represents the value of the i^th card. A pair of cards are matching if the cards have the same value.
Return the minimum number of consecutive cards you have to pick up to have a pair of matching cards among the picked cards. If it is impossible to have matching card... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(cards = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 11\n assert candidate(cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 21\n assert candidate(cards = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n asse... | [
"[3,4,2,3,4,7]",
"[1,0,5,3]"
] | [
"Iterate through the cards and store the location of the last occurrence of each number.",
"What data structure could you use to get the last occurrence of a number in O(1) or O(log n)?"
] | {
"canonical_parameter_names": [
"cards"
],
"leetcode_dataset_entry_point": "Solution().minimumCardPickup",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:39",
"tests_total": 109,
"te... | typescript | {
"raw_signature": "function minimumCardPickup(cards: number[]): number {",
"container": null,
"callable": "minimumCardPickup",
"parameters": [
{
"name": "cards",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
2,261 | k-divisible-elements-subarrays | Medium | Given an integer array nums and two integers k and p, return the number of distinct subarrays, which have at most k elements that are divisible by p.
Two arrays nums1 and nums2 are said to be distinct if:
- They are of different lengths, or
- There exists at least one index i where nums1[i] != nums2[i].
A subarray i... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 1, 2, 1],k = 1,p = 2) == 5\n assert candidate(nums = [19, 23, 29, 31, 37],k = 3,p = 5) == 15\n assert candidate(nums = [1, 2, 1, 2],k = 1,p = 2) == 5\n assert candidate(nums = [13, 26, 39, 52, 65],k = 2,p = 13) == ... | [
"[2,3,3,2,2]\n2\n2",
"[1,2,3,4]\n4\n1"
] | [
"Enumerate all subarrays and find the ones that satisfy all the conditions.",
"Use any suitable method to hash the subarrays to avoid duplicates."
] | {
"canonical_parameter_names": [
"nums",
"k",
"p"
],
"leetcode_dataset_entry_point": "Solution().countDistinct",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:41",
"tests_total... | typescript | {
"raw_signature": "function countDistinct(nums: number[], k: number, p: number): number {",
"container": null,
"callable": "countDistinct",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
},
{
"name": "p",
"type": "... |
2,262 | total-appeal-of-a-string | Hard | The appeal of a string is the number of distinct characters found in the string.
- For example, the appeal of "abbca" is 3 because it has 3 distinct characters: 'a', 'b', and 'c'.
Given a string s, return the total appeal of all of its substrings.
A substring is a contiguous sequence of characters within a string.
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 3276\n assert candidate(s = \"zzzaaa\") == 30\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"abacabadabacaba\") == 357\n assert candidate(s = \"abcabcabc\") == 109\n asse... | [
"\"abbca\"",
"\"code\""
] | [
"Consider the set of substrings that end at a certain index i. Then, consider a specific alphabetic character. How do you count the number of substrings ending at index i that contain that character?",
"The number of substrings that contain the alphabetic character is equivalent to 1 plus the index of the last oc... | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().appealSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:44",
"tests_total": 69,
"tests_dropped":... | typescript | {
"raw_signature": "function appealSum(s: string): number {",
"container": null,
"callable": "appealSum",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,264 | largest-3-same-digit-number-in-string | Easy | You are given a string num representing a large integer. An integer is good if it meets the following conditions:
- It is a substring of num with length 3.
- It consists of only one unique digit.
Return the maximum good integer as a string or an empty string "" if no such integer exists.
Note:
- A substring is a co... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = \"999888777666555444333222111000\") == \"999\"\n assert candidate(num = \"000\") == \"000\"\n assert candidate(num = \"42352338\") == \"\"\n assert candidate(num = \"9876543210\") == \"\"\n assert candidate(num = \"5554... | [
"\"6777133339\"",
"\"2300019\"",
"\"42352338\""
] | [
"We can sequentially check if “999”, “888”, “777”, … , “000” exists in num in that order. The first to be found is the maximum good integer.",
"If we cannot find any of the above integers, we return an empty string “”."
] | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().largestGoodInteger",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:48",
"tests_total": 133,
"tes... | typescript | {
"raw_signature": "function largestGoodInteger(num: string): string {",
"container": null,
"callable": "largestGoodInteger",
"parameters": [
{
"name": "num",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
2,266 | count-number-of-texts | Medium | Alice is texting Bob using her phone. The mapping of digits to letters is shown in the figure below.
In order to add a letter, Alice has to press the key of the corresponding digit i times, where i is the position of the letter in the key.
- For example, to add the letter 's', Alice has to press '7' four times. Simil... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(pressedKeys = \"99999999\") == 108\n assert candidate(pressedKeys = \"3333\") == 7\n assert candidate(pressedKeys = \"33\") == 2\n assert candidate(pressedKeys = \"4444\") == 7\n assert candidate(pressedKeys = \"555555\") == ... | [
"\"22233\"",
"\"222222222222222222222222222222222222\""
] | [
"For a substring consisting of the same digit, how can we count the number of texts it could have originally represented?",
"How can dynamic programming help us calculate the required answer?"
] | {
"canonical_parameter_names": [
"pressedKeys"
],
"leetcode_dataset_entry_point": "Solution().countTexts",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:52",
"tests_total": 38,
"test... | typescript | {
"raw_signature": "function countTexts(pressedKeys: string): number {",
"container": null,
"callable": "countTexts",
"parameters": [
{
"name": "pressedKeys",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
2,267 | check-if-there-is-a-valid-parentheses-string-path | Hard | A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true:
- It is ().
- It can be written as AB (A concatenated with B), where A and B are valid parentheses strings.
- It can be written as (A), where A is a valid parentheses string.
You are give... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [['(', '(', '('], [')', '(', ')'], ['(', '(', ')'], ['(', '(', ')']]) == True\n assert candidate(grid = [[')', ')'], ['(', '(']]) == False\n assert candidate(grid = [[')', '('], ['(', '(']]) == False\n assert candidate(gr... | [
"[[\"(\",\"(\",\"(\"],[\")\",\"(\",\")\"],[\"(\",\"(\",\")\"],[\"(\",\"(\",\")\"]]",
"[[\")\",\")\"],[\"(\",\"(\"]]"
] | [
"What observations can you make about the number of open brackets and close brackets for any prefix of a valid bracket sequence?",
"The number of open brackets must always be greater than or equal to the number of close brackets.",
"Could you use dynamic programming?"
] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().hasValidPath",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:55",
"tests_total": 54,
"tests_dro... | typescript | {
"raw_signature": "function hasValidPath(grid: string[][]): boolean {",
"container": null,
"callable": "hasValidPath",
"parameters": [
{
"name": "grid",
"type": "string[][]"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
2,269 | find-the-k-beauty-of-a-number | Easy | The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions:
- It has a length of k.
- It is a divisor of num.
Given integers num and k, return the k-beauty of num.
Note:
- Leading zeros are allowed.
- 0 is not a divisor of any value.
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = 100000,k = 2) == 1\n assert candidate(num = 240,k = 2) == 2\n assert candidate(num = 1111,k = 2) == 3\n assert candidate(num = 430043,k = 2) == 2\n assert candidate(num = 99999,k = 5) == 1\n assert candidate(num = 12... | [
"240\n2",
"430043\n2"
] | [
"We should check all the substrings of num with a length of k and see if it is a divisor of num.",
"We can more easily obtain the substrings by converting num into a string and converting back to an integer to check for divisibility."
] | {
"canonical_parameter_names": [
"num",
"k"
],
"leetcode_dataset_entry_point": "Solution().divisorSubstrings",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:46:59",
"tests_total": 90,... | typescript | {
"raw_signature": "function divisorSubstrings(num: number, k: number): number {",
"container": null,
"callable": "divisorSubstrings",
"parameters": [
{
"name": "num",
"type": "number"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_sourc... |
2,270 | number-of-ways-to-split-array | Medium | You are given a 0-indexed integer array nums of length n.
nums contains a valid split at index i if the following are true:
- The sum of the first i + 1 elements is greater than or equal to the sum of the last n - i - 1 elements.
- There is at least one element to the right of i. That is, 0 <= i < n - 1.
Return the ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [-100000, -100000, -100000, -100000, -100000]) == 2\n assert candidate(nums = [1, -1, 1, -1, 1]) == 2\n assert candidate(nums = [100, -50, 50, -25, 25]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3... | [
"[10,4,-8,7]",
"[2,3,1,0]"
] | [
"For any index i, how can we find the sum of the first (i+1) elements from the sum of the first i elements?",
"If the total sum of the array is known, how can we check if the sum of the first (i+1) elements greater than or equal to the remaining elements?"
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().waysToSplitArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:02",
"tests_total": 105,
"test... | typescript | {
"raw_signature": "function waysToSplitArray(nums: number[]): number {",
"container": null,
"callable": "waysToSplitArray",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
2,271 | maximum-white-tiles-covered-by-a-carpet | Medium | You are given a 2D integer array tiles where tiles[i] = [l_i, r_i] represents that every tile j in the range l_i <= j <= r_i is colored white.
You are also given an integer carpetLen, the length of a single carpet that can be placed anywhere.
Return the maximum number of white tiles that can be covered by the carpet.... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(tiles = [[1, 1000000000]],carpetLen = 1000000000) == 1000000000\n assert candidate(tiles = [[1, 10], [11, 20], [21, 30]],carpetLen = 15) == 15\n assert candidate(tiles = [[1, 2], [4, 5], [7, 8], [10, 11]],carpetLen = 3) == 2\n a... | [
"[[1,5],[10,11],[12,18],[20,25],[30,32]]\n10",
"[[10,11],[1,1]]\n2"
] | [
"Think about the potential placements of the carpet in an optimal solution.",
"Can we use Prefix Sum and Binary Search to determine how many tiles are covered for a given placement?"
] | {
"canonical_parameter_names": [
"tiles",
"carpetLen"
],
"leetcode_dataset_entry_point": "Solution().maximumWhiteTiles",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:04",
"tests_t... | typescript | {
"raw_signature": "function maximumWhiteTiles(tiles: number[][], carpetLen: number): number {",
"container": null,
"callable": "maximumWhiteTiles",
"parameters": [
{
"name": "tiles",
"type": "number[][]"
},
{
"name": "carpetLen",
"type": "number"
}
],
"return_type": ... |
2,272 | substring-with-largest-variance | Hard | The variance of a string is defined as the largest difference between the number of occurrences of any 2 characters present in the string. Note the two characters may or may not be the same.
Given a string s consisting of lowercase English letters only, return the largest variance possible among all substrings of s.
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"zzzzzzy\") == 5\n assert candidate(s = \"zyzzyzyzy\") == 2\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(s = \"abbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candid... | [
"\"aababbb\"",
"\"abcde\""
] | [
"Think about how to solve the problem if the string had only two distinct characters.",
"If we replace all occurrences of the first character by +1 and those of the second character by -1, can we efficiently calculate the largest possible variance of a string with only two distinct characters?",
"Now, try findi... | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().largestVariance",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:07",
"tests_total": 25,
"tests_dro... | typescript | {
"raw_signature": "function largestVariance(s: string): number {",
"container": null,
"callable": "largestVariance",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,273 | find-resultant-array-after-removing-anagrams | Easy | You are given a 0-indexed string array words, where words[i] consists of lowercase English letters.
In one operation, select any index i such that 0 < i < words.length and words[i - 1] and words[i] are anagrams, and delete words[i] from words. Keep performing this operation as long as you can select an index that sati... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(words = ['abc', 'cab', 'bca', 'xyz', 'zyx', 'yxz']) == ['abc', 'xyz']\n assert candidate(words = ['abc', 'cba', 'bca', 'xyz', 'zyx']) == ['abc', 'xyz']\n assert candidate(words = ['unique', 'words', 'here', 'now']) == ['unique', 'w... | [
"[\"abba\",\"baba\",\"bbaa\",\"cd\",\"cd\"]",
"[\"a\",\"b\",\"c\",\"d\",\"e\"]"
] | [
"Instead of removing each repeating anagram, try to find all the strings in words which will not be present in the final answer.",
"For every index i, find the largest index j < i such that words[j] will be present in the final answer.",
"Check if words[i] and words[j] are anagrams. If they are, then it can be ... | {
"canonical_parameter_names": [
"words"
],
"leetcode_dataset_entry_point": "Solution().removeAnagrams",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:09",
"tests_total": 86,
"tests_... | typescript | {
"raw_signature": "function removeAnagrams(words: string[]): string[] {",
"container": null,
"callable": "removeAnagrams",
"parameters": [
{
"name": "words",
"type": "string[]"
}
],
"return_type": "string[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
2,274 | maximum-consecutive-floors-without-special-floors | Medium | Alice manages a company and has rented some floors of a building as office space. Alice has decided some of these floors should be special floors, used for relaxation only.
You are given two integers bottom and top, which denote that Alice has rented all the floors from bottom to top (inclusive). You are also given th... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(bottom = 3,top = 7,special = [3, 4, 5, 6, 7]) == 0\n assert candidate(bottom = 1,top = 1,special = [1]) == 0\n assert candidate(bottom = 1,top = 10,special = [3, 5, 7, 9]) == 2\n assert candidate(bottom = 6,top = 8,special = [7,... | [
"2\n9\n[4,6]",
"6\n8\n[7,6,8]"
] | [
"Say we have a pair of special floors (x, y) with no other special floors in between. There are x - y - 1 consecutive floors in between them without a special floor.",
"Say there are n special floors. After sorting special, we have answer = max(answer, special[i] – special[i – 1] – 1) for all 0 < i < n.",
"Howe... | {
"canonical_parameter_names": [
"bottom",
"top",
"special"
],
"leetcode_dataset_entry_point": "Solution().maxConsecutive",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:12",
"... | typescript | {
"raw_signature": "function maxConsecutive(bottom: number, top: number, special: number[]): number {",
"container": null,
"callable": "maxConsecutive",
"parameters": [
{
"name": "bottom",
"type": "number"
},
{
"name": "top",
"type": "number"
},
{
"name": "speci... |
2,275 | largest-combination-with-bitwise-and-greater-than-zero | Medium | The bitwise AND of an array nums is the bitwise AND of all integers in nums.
- For example, for nums = [1, 5, 3], the bitwise AND is equal to 1 & 5 & 3 = 1.
- Also, for nums = [7], the bitwise AND is 7.
You are given an array of positive integers candidates. Compute the bitwise AND for all possible combinations of el... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(candidates = [16, 17, 71, 62, 12, 24, 14]) == 4\n assert candidate(candidates = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 16\n assert candidate(candidates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert ca... | [
"[16,17,71,62,12,24,14]",
"[8,8]"
] | [
"For the bitwise AND to be greater than zero, at least one bit should be 1 for every number in the combination.",
"The candidates are 24 bits long, so for every bit position, we can calculate the size of the largest combination such that the bitwise AND will have a 1 at that bit position."
] | {
"canonical_parameter_names": [
"candidates"
],
"leetcode_dataset_entry_point": "Solution().largestCombination",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:14",
"tests_total": 92,
... | typescript | {
"raw_signature": "function largestCombination(candidates: number[]): number {",
"container": null,
"callable": "largestCombination",
"parameters": [
{
"name": "candidates",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": ... |
2,278 | percentage-of-letter-in-string | Easy | Given a string s and a character letter, return the percentage of characters in s that equal letter rounded down to the nearest whole percent.
Example 1:
Input: s = "foobar", letter = "o"
Output: 33
Explanation:
The percentage of characters in s that equal the letter 'o' is 2 / 6 * 100% = 33% when rounded down, so we... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"jjjj\",letter = \"k\") == 0\n assert candidate(s = \"foobar\",letter = \"o\") == 33\n assert candidate(s = \"mississippi\",letter = \"i\") == 36\n assert candidate(s = \"python\",letter = \"y\") == 16\n assert candidate... | [
"\"foobar\"\n\"o\"",
"\"jjjj\"\n\"k\""
] | [
"Can we count the number of occurrences of letter in s?",
"Recall that the percentage is calculated as (occurrences / total) * 100."
] | {
"canonical_parameter_names": [
"s",
"letter"
],
"leetcode_dataset_entry_point": "Solution().percentageLetter",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:19",
"tests_total": 1... | typescript | {
"raw_signature": "function percentageLetter(s: string, letter: string): number {",
"container": null,
"callable": "percentageLetter",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "letter",
"type": "string"
}
],
"return_type": "number",
"signature_s... |
2,279 | maximum-bags-with-full-capacity-of-rocks | Medium | You have n bags numbered from 0 to n - 1. You are given two 0-indexed integer arrays capacity and rocks. The i^th bag can hold a maximum of capacity[i] rocks and currently contains rocks[i] rocks. You are also given an integer additionalRocks, the number of additional rocks you can place in any of the bags.
Return the... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(capacity = [2, 3, 4, 5],rocks = [1, 2, 4, 4],additionalRocks = 2) == 3\n assert candidate(capacity = [1, 2, 3],rocks = [0, 0, 0],additionalRocks = 5) == 2\n assert candidate(capacity = [3, 2, 1],rocks = [0, 0, 0],additionalRocks = ... | [
"[2,3,4,5]\n[1,2,4,4]\n2",
"[10,2,2]\n[2,2,0]\n100"
] | [
"Which bag should you fill completely first?",
"Can you think of a greedy solution?"
] | {
"canonical_parameter_names": [
"capacity",
"rocks",
"additionalRocks"
],
"leetcode_dataset_entry_point": "Solution().maximumBags",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47... | typescript | {
"raw_signature": "function maximumBags(capacity: number[], rocks: number[], additionalRocks: number): number {",
"container": null,
"callable": "maximumBags",
"parameters": [
{
"name": "capacity",
"type": "number[]"
},
{
"name": "rocks",
"type": "number[]"
},
{
... |
2,280 | minimum-lines-to-represent-a-line-chart | Medium | You are given a 2D integer array stockPrices where stockPrices[i] = [day_i, price_i] indicates the price of the stock on day day_i is price_i. A line chart is created from the array by plotting the points on an XY plane with the X-axis representing the day and the Y-axis representing the price and connecting adjacent p... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(stockPrices = [[3, 4], [1, 2], [7, 8], [2, 3]]) == 1\n assert candidate(stockPrices = [[1, 7], [2, 6], [3, 5], [4, 4], [5, 4], [6, 3], [7, 2], [8, 1]]) == 3\n assert candidate(stockPrices = [[1, 1], [2, 3], [4, 5], [6, 7], [8, 9], ... | [
"[[1,7],[2,6],[3,5],[4,4],[5,4],[6,3],[7,2],[8,1]]",
"[[3,4],[1,2],[7,8],[2,3]]"
] | [
"When will three adjacent points lie on the same line? How can we generalize this for all points?",
"Will calculating the slope of lines connecting adjacent points help us find the answer?"
] | {
"canonical_parameter_names": [
"stockPrices"
],
"leetcode_dataset_entry_point": "Solution().minimumLines",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:23",
"tests_total": 107,
"t... | typescript | {
"raw_signature": "function minimumLines(stockPrices: number[][]): number {",
"container": null,
"callable": "minimumLines",
"parameters": [
{
"name": "stockPrices",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetc... |
2,281 | sum-of-total-strength-of-wizards | Hard | As the ruler of a kingdom, you have an army of wizards at your command.
You are given a 0-indexed integer array strength, where strength[i] denotes the strength of the i^th wizard. For a contiguous group of wizards (i.e. the wizards' strengths form a subarray of strength), the total strength is defined as the product ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(strength = [1]) == 1\n assert candidate(strength = [1, 1, 1, 1, 1]) == 35\n assert candidate(strength = [10, 9, 8, 7, 6]) == 1988\n assert candidate(strength = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4576\n assert candidate(stren... | [
"[1,3,1,2]",
"[5,4,6]"
] | [
"Consider the contribution of each wizard to the answer.",
"Can you efficiently calculate the total contribution to the answer for all subarrays that end at each index?",
"Denote the total contribution of all subarrays ending at index i as solve[i]. Can you express solve[i] in terms of solve[m] for some m < i?"... | {
"canonical_parameter_names": [
"strength"
],
"leetcode_dataset_entry_point": "Solution().totalStrength",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:26",
"tests_total": 104,
"tes... | typescript | {
"raw_signature": "function totalStrength(strength: number[]): number {",
"container": null,
"callable": "totalStrength",
"parameters": [
{
"name": "strength",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
2,283 | check-if-number-has-equal-digit-count-and-digit-value | Easy | You are given a 0-indexed string num of length n consisting of digits.
Return true if for every index i in the range 0 <= i < n, the digit i occurs num[i] times in num, otherwise return false.
Example 1:
Input: num = "1210"
Output: true
Explanation:
num[0] = '1'. The digit 0 occurs once in num.
num[1] = '2'. The dig... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = \"1111\") == False\n assert candidate(num = \"00000\") == False\n assert candidate(num = \"10\") == False\n assert candidate(num = \"1111111111\") == False\n assert candidate(num = \"000\") == False\n assert candidat... | [
"\"1210\"",
"\"030\""
] | [
"Count the frequency of each digit in num."
] | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().digitCount",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:30",
"tests_total": 150,
"tests_dropp... | typescript | {
"raw_signature": "function digitCount(num: string): boolean {",
"container": null,
"callable": "digitCount",
"parameters": [
{
"name": "num",
"type": "string"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,284 | sender-with-largest-word-count | Medium | You have a chat log of n messages. You are given two string arrays messages and senders where messages[i] is a message sent by senders[i].
A message is list of words that are separated by a single space with no leading or trailing spaces. The word count of a sender is the total number of words sent by the sender. Note... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(messages = ['This is a test', 'Another test', 'Final test'],senders = ['Alice', 'Bob', 'Alice']) == \"Alice\"\n assert candidate(messages = ['Hi'],senders = ['Bob']) == \"Bob\"\n assert candidate(messages = ['Short', 'Longer messag... | [
"[\"Hello userTwooo\",\"Hi userThree\",\"Wonderful day Alice\",\"Nice day userThree\"]\n[\"Alice\",\"userTwo\",\"userThree\",\"Alice\"]",
"[\"How is leetcode for everyone\",\"Leetcode is useful for practice\"]\n[\"Bob\",\"Charlie\"]"
] | [
"The number of words in a message is equal to the number of spaces + 1.",
"Use a hash map to count the total number of words from each sender."
] | {
"canonical_parameter_names": [
"messages",
"senders"
],
"leetcode_dataset_entry_point": "Solution().largestWordCount",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:33",
"tests_t... | typescript | {
"raw_signature": "function largestWordCount(messages: string[], senders: string[]): string {",
"container": null,
"callable": "largestWordCount",
"parameters": [
{
"name": "messages",
"type": "string[]"
},
{
"name": "senders",
"type": "string[]"
}
],
"return_type": ... |
2,285 | maximum-total-importance-of-roads | Medium | You are given an integer n denoting the number of cities in a country. The cities are numbered from 0 to n - 1.
You are also given a 2D integer array roads where roads[i] = [a_i, b_i] denotes that there exists a bidirectional road connecting cities a_i and b_i.
You need to assign each city with an integer value from ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 5,roads = [[0, 1], [1, 2], [2, 3], [0, 2], [1, 3], [2, 4]]) == 43\n assert candidate(n = 6,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == 45\n assert candidate(n = 3,roads = [[0, 1], [1, 2]]) == 9\n assert candidate(n ... | [
"5\n[[0,1],[1,2],[2,3],[0,2],[1,3],[2,4]]",
"5\n[[0,3],[2,4],[1,3]]"
] | [
"Consider what each city contributes to the total importance of all roads.",
"Based on that, how can you sort the cities such that assigning them values in that order will yield the maximum total importance?"
] | {
"canonical_parameter_names": [
"n",
"roads"
],
"leetcode_dataset_entry_point": "Solution().maximumImportance",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:35",
"tests_total": 6... | typescript | {
"raw_signature": "function maximumImportance(n: number, roads: number[][]): number {",
"container": null,
"callable": "maximumImportance",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "roads",
"type": "number[][]"
}
],
"return_type": "number",
"sig... |
2,287 | rearrange-characters-to-make-target-string | Easy | You are given two 0-indexed strings s and target. You can take some letters from s and rearrange them to form new strings.
Return the maximum number of copies of target that can be formed by taking letters from s and rearranging them.
Example 1:
Input: s = "ilovecodingonleetcode", target = "code"
Output: 2
Explanati... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"aabbc\",target = \"abc\") == 1\n assert candidate(s = \"aabbbccc\",target = \"abc\") == 2\n assert candidate(s = \"zzzz\",target = \"zz\") == 2\n assert candidate(s = \"abcabcabc\",target = \"abc\") == 3\n assert candid... | [
"\"ilovecodingonleetcode\"\n\"code\"",
"\"abcba\"\n\"abc\"",
"\"abbaccaddaeea\"\n\"aaaaa\""
] | [
"Count the frequency of each character in s and target.",
"Consider each letter one at a time. If there are x occurrences of a letter in s and y occurrences of the same letter in target, how many copies of this letter can we make?",
"We can make floor(x / y) copies of the letter."
] | {
"canonical_parameter_names": [
"s",
"target"
],
"leetcode_dataset_entry_point": "Solution().rearrangeCharacters",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:37",
"tests_total"... | typescript | {
"raw_signature": "function rearrangeCharacters(s: string, target: string): number {",
"container": null,
"callable": "rearrangeCharacters",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "target",
"type": "string"
}
],
"return_type": "number",
"signa... |
2,288 | apply-discount-to-prices | Medium | A sentence is a string of single-space separated words where each word can contain digits, lowercase letters, and the dollar sign '$'. A word represents a price if it is a sequence of digits preceded by a dollar sign.
- For example, "$100", "$23", and "$6" represent prices while "100", "$", and "$1e5" do not.
You are... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(sentence = \"$10 $20 $30 $40 $50\",discount = 0) == \"$10.00 $20.00 $30.00 $40.00 $50.00\"\n assert candidate(sentence = \"$100 $200 $300\",discount = 25) == \"$75.00 $150.00 $225.00\"\n assert candidate(sentence = \"no prices here... | [
"\"there are $1 $2 and 5$ candies in the shop\"\n50",
"\"1 2 $3 4 $5 $6 7 8$ $9 $10$\"\n100"
] | [
"Extract each word from the sentence and check if it represents a price.",
"For each price, apply the given discount to it and update it."
] | {
"canonical_parameter_names": [
"sentence",
"discount"
],
"leetcode_dataset_entry_point": "Solution().discountPrices",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:40",
"tests_to... | typescript | {
"raw_signature": "function discountPrices(sentence: string, discount: number): string {",
"container": null,
"callable": "discountPrices",
"parameters": [
{
"name": "sentence",
"type": "string"
},
{
"name": "discount",
"type": "number"
}
],
"return_type": "string",
... |
2,289 | steps-to-make-array-non-decreasing | Medium | You are given a 0-indexed integer array nums. In one step, remove all elements nums[i] where nums[i - 1] > nums[i] for all 0 < i < nums.length.
Return the number of steps performed until nums becomes a non-decreasing array.
Example 1:
Input: nums = [5,3,4,4,7,3,6,11,8,5,11]
Output: 3
Explanation: The following are t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 1\n assert candidate(nums = [3, 2, 1, 2, 1, 2, 3, 2, 1]) == 3\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000... | [
"[5,3,4,4,7,3,6,11,8,5,11]",
"[4,5,7,7,13]"
] | [
"Notice that an element will be removed if and only if there exists a strictly greater element to the left of it in the array.",
"For each element, we need to find the number of rounds it will take for it to be removed. The answer is the maximum number of rounds for all elements. Build an array dp to hold this in... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().totalSteps",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:42",
"tests_total": 129,
"tests_drop... | typescript | {
"raw_signature": "function totalSteps(nums: number[]): number {",
"container": null,
"callable": "totalSteps",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,290 | minimum-obstacle-removal-to-reach-corner | Hard | You are given a 0-indexed 2D integer array grid of size m x n. Each cell has one of two values:
- 0 represents an empty cell,
- 1 represents an obstacle that may be removed.
You can move up, down, left, or right from and to an empty cell.
Return the minimum number of obstacles to remove so you can move from the uppe... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[0, 1], [1, 0]]) == 1\n assert candidate(grid = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 0]]) == 4\n assert candidate(grid = [[0, 1, 1, 0], [1, 1, 1, 0], [1... | [
"[[0,1,1],[1,1,0],[1,1,0]]",
"[[0,1,0,0,0],[0,1,0,1,0],[0,0,0,1,0]]"
] | [
"Model the grid as a graph where cells are nodes and edges are between adjacent cells. Edges to cells with obstacles have a cost of 1 and all other edges have a cost of 0.",
"Could you use 0-1 Breadth-First Search or Dijkstra’s algorithm?"
] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().minimumObstacles",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:45",
"tests_total": 59,
"tests... | typescript | {
"raw_signature": "function minimumObstacles(grid: number[][]): number {",
"container": null,
"callable": "minimumObstacles",
"parameters": [
{
"name": "grid",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
2,293 | min-max-game | Easy | You are given a 0-indexed integer array nums whose length is a power of 2.
Apply the following algorithm on nums:
1. Let n be the length of nums. If n == 1, end the process. Otherwise, create a new 0-indexed integer array newNums of length n / 2.
2. For every even index i where 0 <= i < n / 2, assign the value of new... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 2, 4, 8, 2, 2]) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1000000000\n assert candidate(nums = [5, 1, 4, 2, 7, 6, 3, 8]) == ... | [
"[1,3,5,2,4,8,2,2]",
"[3]"
] | [
"Simply simulate the algorithm.",
"Note that the size of the array decreases exponentially, so the process will terminate after just O(log n) steps."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().minMaxGame",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:49",
"tests_total": 93,
"tests_dropp... | typescript | {
"raw_signature": "function minMaxGame(nums: number[]): number {",
"container": null,
"callable": "minMaxGame",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,294 | partition-array-such-that-maximum-difference-is-k | Medium | You are given an integer array nums and an integer k. You may partition nums into one or more subsequences such that each element in nums appears in exactly one of the subsequences.
Return the minimum number of subsequences needed such that the difference between the maximum and minimum values in each subsequence is a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 100000],k = 99999) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 4\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k... | [
"[3,6,1,2,5]\n2",
"[1,2,3]\n1",
"[2,2,4,5]\n0"
] | [
"Which values in each subsequence matter? The only values that matter are the maximum and minimum values.",
"Let the maximum and minimum values of a subsequence be Max and Min. It is optimal to place all values in between Max and Min in the original array in the same subsequence as Max and Min.",
"Sort the arra... | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().partitionArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:52",
"tests_total": 112,
... | typescript | {
"raw_signature": "function partitionArray(nums: number[], k: number): number {",
"container": null,
"callable": "partitionArray",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_sourc... |
2,295 | replace-elements-in-an-array | Medium | You are given a 0-indexed array nums that consists of n distinct positive integers. Apply m operations to this array, where in the i^th operation you replace the number operations[i][0] with operations[i][1].
It is guaranteed that in the i^th operation:
- operations[i][0] exists in nums.
- operations[i][1] does not e... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2],operations = [[1, 3], [2, 1], [3, 2]]) == [2, 1]\n assert candidate(nums = [5, 3, 7, 8],operations = [[5, 10], [3, 15], [7, 20], [8, 25]]) == [10, 15, 20, 25]\n assert candidate(nums = [1, 2, 3, 4, 5],operations = [[1... | [
"[1,2,4,6]\n[[1,3],[4,7],[6,1]]",
"[1,2]\n[[1,3],[2,1],[3,2]]"
] | [
"Can you think of a data structure that will allow you to store the position of each number?",
"Use that data structure to instantly replace a number with its new value."
] | {
"canonical_parameter_names": [
"nums",
"operations"
],
"leetcode_dataset_entry_point": "Solution().arrayChange",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:47:54",
"tests_total":... | typescript | {
"raw_signature": "function arrayChange(nums: number[], operations: number[][]): number[] {",
"container": null,
"callable": "arrayChange",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "operations",
"type": "number[][]"
}
],
"return_type": "numbe... |
2,300 | successful-pairs-of-spells-and-potions | Medium | You are given two positive integer arrays spells and potions, of length n and m respectively, where spells[i] represents the strength of the i^th spell and potions[j] represents the strength of the j^th potion.
You are also given an integer success. A spell and potion pair is considered successful if the product of th... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(spells = [3, 1, 2],potions = [8, 5, 8],success = 16) == [2, 0, 2]\n assert candidate(spells = [1, 1, 1],potions = [1, 1, 1],success = 2) == [0, 0, 0]\n assert candidate(spells = [5, 1, 3],potions = [1, 2, 3, 4, 5],success = 7) == [... | [
"[5,1,3]\n[1,2,3,4,5]\n7",
"[3,1,2]\n[8,5,8]\n16"
] | [
"Notice that if a spell and potion pair is successful, then the spell and all stronger potions will be successful too.",
"Thus, for each spell, we need to find the potion with the least strength that will form a successful pair.",
"We can efficiently do this by sorting the potions based on strength and using bi... | {
"canonical_parameter_names": [
"spells",
"potions",
"success"
],
"leetcode_dataset_entry_point": "Solution().successfulPairs",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:48:01"... | typescript | {
"raw_signature": "function successfulPairs(spells: number[], potions: number[], success: number): number[] {",
"container": null,
"callable": "successfulPairs",
"parameters": [
{
"name": "spells",
"type": "number[]"
},
{
"name": "potions",
"type": "number[]"
},
{
... |
2,301 | match-substring-after-replacement | Hard | You are given two strings s and sub. You are also given a 2D character array mappings where mappings[i] = [old_i, new_i] indicates that you may perform the following operation any number of times:
- Replace a character old_i of sub with new_i.
Each character in sub cannot be replaced more than once.
Return true if i... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"fooleetbar\",sub = \"f00l\",mappings = [['o', '0']]) == False\n assert candidate(s = \"fool3e7bar\",sub = \"leet\",mappings = [['e', '3'], ['t', '7'], ['t', '8']]) == True\n assert candidate(s = \"Fool33tbaR\",sub = \"leetd\"... | [
"\"fool3e7bar\"\n\"leet\"\n[[\"e\",\"3\"],[\"t\",\"7\"],[\"t\",\"8\"]]",
"\"fooleetbar\"\n\"f00l\"\n[[\"o\",\"0\"]]",
"\"Fool33tbaR\"\n\"leetd\"\n[[\"e\",\"3\"],[\"t\",\"7\"],[\"t\",\"8\"],[\"d\",\"b\"],[\"p\",\"b\"]]"
] | [
"Enumerate all substrings of s with the same length as sub, and compare each substring to sub for equality.",
"How can you quickly tell if a character of s can result from replacing the corresponding character in sub?"
] | {
"canonical_parameter_names": [
"s",
"sub",
"mappings"
],
"leetcode_dataset_entry_point": "Solution().matchReplacement",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:48:03",
"te... | typescript | {
"raw_signature": "function matchReplacement(s: string, sub: string, mappings: string[][]): boolean {",
"container": null,
"callable": "matchReplacement",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "sub",
"type": "string"
},
{
"name": "mapping... |
2,302 | count-subarrays-with-score-less-than-k | Hard | The score of an array is defined as the product of its sum and its length.
- For example, the score of [1, 2, 3, 4, 5] is (1 + 2 + 3 + 4 + 5) * 5 = 75.
Given a positive integer array nums and an integer k, return the number of non-empty subarrays of nums whose score is strictly less than k.
A subarray is a contiguou... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],k = 100) == 15\n assert candidate(nums = [10, 10, 10],k = 100) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 24\n assert candidate(nums = [1, 1, 1],k = 5) == 5\n assert candi... | [
"[2,1,4,3,5]\n10",
"[1,1,1]\n5"
] | [
"If we add an element to a list of elements, how will the score change?",
"How can we use this to determine the number of subarrays with score less than k in a given range?",
"How can we use “Two Pointers” to generalize the solution, and thus count all possible subarrays?"
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().countSubarrays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:48:06",
"tests_total": 79,
... | typescript | {
"raw_signature": "function countSubarrays(nums: number[], k: number): number {",
"container": null,
"callable": "countSubarrays",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_sourc... |
2,303 | calculate-amount-paid-in-taxes | Easy | You are given a 0-indexed 2D integer array brackets where brackets[i] = [upper_i, percent_i] means that the i^th tax bracket has an upper bound of upper_i and is taxed at a rate of percent_i. The brackets are sorted by upper bound (i.e. upper_{i-1} < upper_i for 0 < i < brackets.length).
Tax is calculated as follows:
... | {
"language": "python",
"source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_mat... | [
"[[3,50],[7,10],[12,25]]\n10",
"[[1,0],[4,25],[5,50]]\n2",
"[[2,50]]\n0"
] | [
"As you iterate through the tax brackets, keep track of the previous tax bracket’s upper bound in a variable called prev. If there is no previous tax bracket, use 0 instead.",
"The amount of money in the ith tax bracket is min(income, upperi) - prev."
] | {
"canonical_parameter_names": [
"brackets",
"income"
],
"leetcode_dataset_entry_point": "Solution().calculateTax",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:48:08",
"tests_total"... | typescript | {
"raw_signature": "function calculateTax(brackets: number[][], income: number): number {",
"container": null,
"callable": "calculateTax",
"parameters": [
{
"name": "brackets",
"type": "number[][]"
},
{
"name": "income",
"type": "number"
}
],
"return_type": "number",
... |
2,304 | minimum-path-cost-in-a-grid | Medium | You are given a 0-indexed m x n integer matrix grid consisting of distinct integers from 0 to m * n - 1. You can move in this matrix from a cell to any other cell in the next row. That is, if you are in cell (x, y) such that x < m - 1, you can move to any of the cells (x + 1, 0), (x + 1, 1), ..., (x + 1, n - 1). Note t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],moveCost = [[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]]) == 29\n assert candidate(grid = [[1, 2, 3], [4, 5, 6]],moveCost... | [
"[[5,3],[4,0],[2,1]]\n[[9,8],[1,5],[10,12],[18,6],[2,4],[14,3]]",
"[[5,1,2],[4,0,3]]\n[[12,10,15],[20,23,8],[21,7,1],[8,1,13],[9,10,25],[5,3,2]]"
] | [
"What is the optimal cost to get to each of the cells in the second row? What about the third row?",
"Use dynamic programming to compute the optimal cost to get to each cell."
] | {
"canonical_parameter_names": [
"grid",
"moveCost"
],
"leetcode_dataset_entry_point": "Solution().minPathCost",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:48:10",
"tests_total": 2... | typescript | {
"raw_signature": "function minPathCost(grid: number[][], moveCost: number[][]): number {",
"container": null,
"callable": "minPathCost",
"parameters": [
{
"name": "grid",
"type": "number[][]"
},
{
"name": "moveCost",
"type": "number[][]"
}
],
"return_type": "number"... |
2,305 | fair-distribution-of-cookies | Medium | You are given an integer array cookies, where cookies[i] denotes the number of cookies in the i^th bag. You are also given an integer k that denotes the number of children to distribute all the bags of cookies to. All the cookies in the same bag must go to the same child and cannot be split up.
The unfairness of a dis... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(cookies = [1, 1, 1, 1, 1, 1, 1, 100000],k = 7) == 100000\n assert candidate(cookies = [8, 15, 10, 20, 8],k = 2) == 31\n assert candidate(cookies = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 8) == 100000\n ... | [
"[8,15,10,20,8]\n2",
"[6,1,3,2,2,4,1,2]\n3"
] | [
"We have to give each bag to one of the children. How can we enumerate all of the possibilities?",
"Use recursion and keep track of the current number of cookies each child has. Once all the bags have been distributed, find the child with the most cookies."
] | {
"canonical_parameter_names": [
"cookies",
"k"
],
"leetcode_dataset_entry_point": "Solution().distributeCookies",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:48:13",
"tests_total":... | typescript | {
"raw_signature": "function distributeCookies(cookies: number[], k: number): number {",
"container": null,
"callable": "distributeCookies",
"parameters": [
{
"name": "cookies",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"sig... |
2,306 | naming-a-company | Hard | You are given an array of strings ideas that represents a list of names to be used in the process of naming a company. The process of naming a company is as follows:
1. Choose 2 distinct names from ideas, call them idea_A and idea_B.
2. Swap the first letters of idea_A and idea_B with each other.
3. If both of the new... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(ideas = ['coffee', 'donuts', 'time', 'toffee']) == 6\n assert candidate(ideas = ['aaa', 'bbb', 'ccc']) == 6\n assert candidate(ideas = ['abc', 'bcd', 'cde', 'dec']) == 12\n assert candidate(ideas = ['abcd', 'dcba', 'ddda', 'dccd... | [
"[\"coffee\",\"donuts\",\"time\",\"toffee\"]",
"[\"lack\",\"back\"]"
] | [
"How can we divide the ideas into groups to make it easier to find valid pairs?",
"Group ideas that share the same suffix (all characters except the first) together and notice that a pair of ideas from the same group is invalid. What about pairs of ideas from different groups?",
"The first letter of the idea in... | {
"canonical_parameter_names": [
"ideas"
],
"leetcode_dataset_entry_point": "Solution().distinctNames",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:48:15",
"tests_total": 45,
"tests_d... | typescript | {
"raw_signature": "function distinctNames(ideas: string[]): number {",
"container": null,
"callable": "distinctNames",
"parameters": [
{
"name": "ideas",
"type": "string[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
2,309 | greatest-english-letter-in-upper-and-lower-case | Easy | Given a string of English letters s, return the greatest English letter which occurs as both a lowercase and uppercase letter in s. The returned letter should be in uppercase. If no such letter exists, return an empty string.
An English letter b is greater than another letter a if b appears after a in the English alph... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n assert candidate(s = \"mMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"Z\"\n assert candidate(s = \"zZyYxXwWeE\") == \"Z\"\n assert candidate(s = \"zZyYxXwWvVuUtTrRsS... | [
"\"lEeTcOdE\"",
"\"arRAzFif\"",
"\"AbCdEfGhIjK\""
] | [
"Consider iterating through the string and storing each unique character that occurs in a set.",
"From Z to A, check whether both the uppercase and lowercase version occur in the set."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().greatestLetter",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:48:20",
"tests_total": 117,
"tests_dro... | typescript | {
"raw_signature": "function greatestLetter(s: string): string {",
"container": null,
"callable": "greatestLetter",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,310 | sum-of-numbers-with-units-digit-k | Medium | Given two integers num and k, consider a set of positive integers with the following properties:
- The units digit of each integer is k.
- The sum of the integers is num.
Return the minimum possible size of such a set, or -1 if no such set exists.
Note:
- The set can contain multiple instances of the same integer, ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = 25,k = 5) == 1\n assert candidate(num = 2023,k = 3) == 1\n assert candidate(num = 37,k = 2) == -1\n assert candidate(num = 100,k = 0) == 1\n assert candidate(num = 58,k = 9) == 2\n assert candidate(num = 99,k = 9) ==... | [
"58\n9",
"37\n2",
"0\n7"
] | [
"Try solving this recursively.",
"Create a method that takes an integer x as a parameter. This method returns the minimum possible size of a set where each number has units digit k and the sum of the numbers in the set is x."
] | {
"canonical_parameter_names": [
"num",
"k"
],
"leetcode_dataset_entry_point": "Solution().minimumNumbers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:48:22",
"tests_total": 114,
... | typescript | {
"raw_signature": "function minimumNumbers(num: number, k: number): number {",
"container": null,
"callable": "minimumNumbers",
"parameters": [
{
"name": "num",
"type": "number"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "l... |
2,311 | longest-binary-subsequence-less-than-or-equal-to-k | Medium | You are given a binary string s and a positive integer k.
Return the length of the longest subsequence of s that makes up a binary number less than or equal to k.
Note:
- The subsequence can contain leading zeroes.
- The empty string is considered to be equal to 0.
- A subsequence is a string that can be derived fro... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"111000111\",k = 127) == 7\n assert candidate(s = \"1111111\",k = 127) == 7\n assert candidate(s = \"1111000011\",k = 255) == 8\n assert candidate(s = \"1100110011\",k = 10) == 6\n assert candidate(s = \"1010101010\",k =... | [
"\"1001010\"\n5",
"\"00101001\"\n1"
] | [
"Choosing a subsequence from the string is equivalent to deleting all the other digits.",
"If you were to remove a digit, which one should you remove to reduce the value of the string?"
] | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().longestSubsequence",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:48:24",
"tests_total": 101,... | typescript | {
"raw_signature": "function longestSubsequence(s: string, k: number): number {",
"container": null,
"callable": "longestSubsequence",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source"... |
2,312 | selling-pieces-of-wood | Hard | You are given two integers m and n that represent the height and width of a rectangular piece of wood. You are also given a 2D integer array prices, where prices[i] = [h_i, w_i, price_i] indicates you can sell a rectangular piece of wood of height h_i and width w_i for price_i dollars.
To cut a piece of wood, you must... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(m = 4,n = 6,prices = [[3, 2, 10], [1, 4, 2], [4, 1, 3]]) == 32\n assert candidate(m = 2,n = 2,prices = [[1, 1, 1], [2, 2, 5]]) == 5\n assert candidate(m = 3,n = 5,prices = [[1, 4, 2], [2, 2, 7], [2, 1, 3]]) == 19\n assert candid... | [
"3\n5\n[[1,4,2],[2,2,7],[2,1,3]]",
"4\n6\n[[3,2,10],[1,4,2],[4,1,3]]"
] | [
"Note down the different actions that can be done on a piece of wood with dimensions m x n. What do you notice?",
"If possible, we could sell the m x n piece. We could also cut the piece vertically creating two pieces of size m x n1 and m x n2 where n1 + n2 = n, or horizontally creating two pieces of size m1 x n ... | {
"canonical_parameter_names": [
"m",
"n",
"prices"
],
"leetcode_dataset_entry_point": "Solution().sellingWood",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:48:27",
"tests_total... | typescript | {
"raw_signature": "function sellingWood(m: number, n: number, prices: number[][]): number {",
"container": null,
"callable": "sellingWood",
"parameters": [
{
"name": "m",
"type": "number"
},
{
"name": "n",
"type": "number"
},
{
"name": "prices",
"type": "... |
2,315 | count-asterisks | Easy | You are given a string s, where every two consecutive vertical bars '|' are grouped into a pair. In other words, the 1^st and 2^nd '|' make a pair, the 3^rd and 4^th '|' make a pair, and so forth.
Return the number of '*' in s, excluding the '*' between each pair of '|'.
Note that each '|' will belong to exactly one ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"iamprogrammer\") == 0\n assert candidate(s = \"|*|*|*|*|\") == 2\n assert candidate(s = \"||||||||||\") == 0\n assert candidate(s = \"yo|uar|e**|b|e***au|tifu|l\") == 5\n assert candidate(s = \"l|*e*et|c**o|*de|\") == 2... | [
"\"l|*e*et|c**o|*de|\"",
"\"iamprogrammer\"",
"\"yo|uar|e**|b|e***au|tifu|l\""
] | [
"Iterate through each character, while maintaining whether we are currently between a pair of ‘|’ or not.",
"If we are not in between a pair of ‘|’ and there is a ‘*’, increment the answer by 1."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().countAsterisks",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:48:29",
"tests_total": 106,
"tests_dro... | typescript | {
"raw_signature": "function countAsterisks(s: string): number {",
"container": null,
"callable": "countAsterisks",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.