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 |
|---|---|---|---|---|---|---|---|---|---|
1,749 | maximum-absolute-sum-of-any-subarray | Medium | You are given an integer array nums. The absolute sum of a subarray [nums_l, nums_{l+1}, ..., nums_{r-1}, nums_r] is abs(nums_l + nums_{l+1} + ... + nums_{r-1} + nums_r).
Return the maximum absolute sum of any (possibly empty) subarray of nums.
Note that abs(x) is defined as follows:
- If x is a negative integer, th... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [-10000, 10000, -10000, 10000]) == 10000\n assert candidate(nums = [1, -3, 2, 3, -4]) == 5\n assert candidate(nums = [0]) == 0\n... | [
"[1,-3,2,3,-4]",
"[2,-5,1,-4,3,-2]"
] | [
"What if we asked for maximum sum, not absolute sum?",
"It's a standard problem that can be solved by Kadane's algorithm.",
"The key idea is the max absolute sum will be either the max sum or the min sum.",
"So just run kadane twice, once calculating the max sum and once calculating the min sum."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maxAbsoluteSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:29:32",
"tests_total": 110,
"tests_... | typescript | {
"raw_signature": "function maxAbsoluteSum(nums: number[]): number {",
"container": null,
"callable": "maxAbsoluteSum",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
1,750 | minimum-length-of-string-after-deleting-similar-ends | Medium | Given a string s consisting only of characters 'a', 'b', and 'c'. You are asked to apply the following algorithm on the string any number of times:
1. Pick a non-empty prefix from the string s where all the characters in the prefix are equal.
2. Pick a non-empty suffix from the string s where all the characters in thi... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abcba\") == 1\n assert candidate(s = \"ca\") == 2\n assert candidate(s = \"abac\") == 4\n assert candidate(s = \"aabccabba\") == 3\n assert candidate(s = \"aabbaa\") == 0\n assert candidate(s = \"aaaaa\") == 0\n a... | [
"\"ca\"",
"\"cabaabac\"",
"\"aabccabba\""
] | [
"If both ends have distinct characters, no more operations can be made. Otherwise, the only operation is to remove all of the same characters from both ends. We will do this as many times as we can.",
"Note that if the length is equal 1 the answer is 1"
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().minimumLength",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:29:34",
"tests_total": 170,
"tests_drop... | typescript | {
"raw_signature": "function minimumLength(s: string): number {",
"container": null,
"callable": "minimumLength",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,751 | maximum-number-of-events-that-can-be-attended-ii | Hard | You are given an array of events where events[i] = [startDay_i, endDay_i, value_i]. The i^th event starts at startDay_iand ends at endDay_i, and if you attend this event, you will receive a value of value_i. You are also given an integer k which represents the maximum number of events you can attend.
You can only atte... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(events = [[1, 5, 4], [11, 15, 1], [8, 10, 2], [2, 11, 6]],k = 3) == 7\n assert candidate(events = [[2, 8, 6], [4, 9, 10], [6, 8, 3]],k = 2) == 10\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [6, 10, 5], [2, 9, 4]],k = 2) == 1... | [
"[[1,2,4],[3,4,3],[2,3,1]]\n2",
"[[1,2,4],[3,4,3],[2,3,10]]\n2",
"[[1,1,1],[2,2,2],[3,3,3],[4,4,4]]\n3"
] | [
"Sort the events by its startTime.",
"For every event, you can either choose it and consider the next event available, or you can ignore it. You can efficiently find the next event that is available using binary search."
] | {
"canonical_parameter_names": [
"events",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxValue",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:29:37",
"tests_total": 108,
"t... | typescript | {
"raw_signature": "function maxValue(events: number[][], k: number): number {",
"container": null,
"callable": "maxValue",
"parameters": [
{
"name": "events",
"type": "number[][]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": ... |
1,752 | check-if-array-is-sorted-and-rotated | Easy | Given an array nums, return true if the array was originally sorted in non-decreasing order, then rotated some number of positions (including zero). Otherwise, return false.
There may be duplicates in the original array.
Note: An array A rotated by x positions results in an array B of the same length such that B[i] =... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [2, 1, 3, 4]) == False\n assert candidate(nums = [1, 3, 2]) == False\n assert candidate(nums = [4, 5, 6, 1, 2, 3]) == True\n assert candidate(nums = [1, 3, 5, 7, 2, 4, 6, 8]) == False\n assert candidate(nums = [2, 2, 1... | [
"[3,4,5,1,2]",
"[2,1,3,4]",
"[1,2,3]"
] | [
"Brute force and check if it is possible for a sorted array to start from each position."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().check",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:29:39",
"tests_total": 141,
"tests_dropped":... | typescript | {
"raw_signature": "function check(nums: number[]): boolean {",
"container": null,
"callable": "check",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,753 | maximum-score-from-removing-stones | Medium | You are playing a solitaire game with three piles of stones of sizes a, b, and c respectively. Each turn you choose two different non-empty piles, take one stone from each, and add 1 point to your score. The game stops when there are fewer than two non-empty piles (meaning there are no more available moves).
Given thr... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(a = 10,b = 10,c = 1) == 10\n assert candidate(a = 5,b = 7,c = 9) == 10\n assert candidate(a = 5,b = 5,c = 5) == 7\n assert candidate(a = 1,b = 8,c = 8) == 8\n assert candidate(a = 3,b = 3,c = 3) == 4\n assert candidate(a =... | [
"2\n4\n6",
"4\n4\n6",
"1\n8\n8"
] | [
"It's optimal to always remove one stone from the biggest 2 piles",
"Note that the limits are small enough for simulation"
] | {
"canonical_parameter_names": [
"a",
"b",
"c"
],
"leetcode_dataset_entry_point": "Solution().maximumScore",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:29:41",
"tests_total": 8... | typescript | {
"raw_signature": "function maximumScore(a: number, b: number, c: number): number {",
"container": null,
"callable": "maximumScore",
"parameters": [
{
"name": "a",
"type": "number"
},
{
"name": "b",
"type": "number"
},
{
"name": "c",
"type": "number"
... |
1,754 | largest-merge-of-two-strings | Medium | You are given two strings word1 and word2. You want to construct a string merge in the following way: while either word1 or word2 are non-empty, choose one of the following options:
- If word1 is non-empty, append the first character in word1 to merge and delete it from word1.
- For example, if word1 = "abc" and mer... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word1 = \"lexicographically\",word2 = \"largestmerge\") == \"llexicogrargestmergeaphically\"\n assert candidate(word1 = \"zyxw\",word2 = \"abcd\") == \"zyxwabcd\"\n assert candidate(word1 = \"abcdabcd\",word2 = \"zyxwzyxw\") == \"z... | [
"\"cabaa\"\n\"bcaaa\"",
"\"abcabc\"\n\"abdcaba\""
] | [
"Build the result character by character. At each step, you choose a character from one of the two strings.",
"If the next character of the first string is larger than that of the second string, or vice versa, it's optimal to use the larger one.",
"If both are equal, think of a criteria that lets you decide whi... | {
"canonical_parameter_names": [
"word1",
"word2"
],
"leetcode_dataset_entry_point": "Solution().largestMerge",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:29:43",
"tests_total": 13... | typescript | {
"raw_signature": "function largestMerge(word1: string, word2: string): string {",
"container": null,
"callable": "largestMerge",
"parameters": [
{
"name": "word1",
"type": "string"
},
{
"name": "word2",
"type": "string"
}
],
"return_type": "string",
"signature_sou... |
1,755 | closest-subsequence-sum | Hard | You are given an integer array nums and an integer goal.
You want to choose a subsequence of nums such that the sum of its elements is the closest possible to goal. That is, if the sum of the subsequence's elements is sum, then you want to minimize the absolute difference abs(sum - goal).
Return the minimum possible ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [-10, -20, -30, -40, -50],goal = -100) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],goal = 100) == 0\n assert candidate(nums = [10, 22, 9, -24, -33, 21, 4, 19, 29, -14, 34, 10, -11, 8, -8, -7, 13, 24, -29, -10, -28, 1... | [
"[5,-7,3,5]\n6",
"[7,-9,15,-2]\n-5",
"[1,2,3]\n-7"
] | [
"The naive solution is to check all possible subsequences. This works in O(2^n).",
"Divide the array into two parts of nearly is equal size.",
"Consider all subsets of one part and make a list of all possible subset sums and sort this list.",
"Consider all subsets of the other part, and for each one, let its ... | {
"canonical_parameter_names": [
"nums",
"goal"
],
"leetcode_dataset_entry_point": "Solution().minAbsDifference",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:29:46",
"tests_total": ... | typescript | {
"raw_signature": "function minAbsDifference(nums: number[], goal: number): number {",
"container": null,
"callable": "minAbsDifference",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "goal",
"type": "number"
}
],
"return_type": "number",
"signa... |
1,758 | minimum-changes-to-make-alternating-binary-string | Easy | You are given a string s consisting only of the characters '0' and '1'. In one operation, you can change any '0' to '1' or vice versa.
The string is called alternating if no two adjacent characters are equal. For example, the string "010" is alternating, while the string "0100" is not.
Return the minimum number of op... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"1111\") == 2\n assert candidate(s = \"101010\") == 0\n assert candidate(s = \"111000\") == 2\n assert candidate(s = \"1101101101\") == 4\n assert candidate(s = \"001100\") == 3\n assert candidate(s = \"10\") == 0\n ... | [
"\"0100\"",
"\"10\"",
"\"1111\""
] | [
"Think about how the final string will look like.",
"It will either start with a '0' and be like '010101010..' or with a '1' and be like '10101010..'",
"Try both ways, and check for each way, the number of changes needed to reach it from the given string. The answer is the minimum of both ways."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().minOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:29:48",
"tests_total": 117,
"tests_drop... | typescript | {
"raw_signature": "function minOperations(s: string): number {",
"container": null,
"callable": "minOperations",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,759 | count-number-of-homogenous-substrings | Medium | Given a string s, return the number of homogenous substrings of s. Since the answer may be too large, return it modulo 10^9 + 7.
A string is homogenous if all the characters of the string are the same.
A substring is a contiguous sequence of characters within a string.
Example 1:
Input: s = "abbcccaa"
Output: 13
Ex... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"aaabbbccc\") == 18\n assert candidate(s = \"aabbccddeeefffggghhhiiii\") == 46\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"xy\") == 2\n assert candidate(s = \"aabbaa\") == 9\n ... | [
"\"abbcccaa\"",
"\"xy\"",
"\"zzzzz\""
] | [
"A string of only 'a's of length k contains k + 1 choose 2 homogenous substrings.",
"Split the string into substrings where each substring contains only one letter, and apply the formula on each substring's length."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().countHomogenous",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:29:50",
"tests_total": 80,
"tests_dro... | typescript | {
"raw_signature": "function countHomogenous(s: string): number {",
"container": null,
"callable": "countHomogenous",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,760 | minimum-limit-of-balls-in-a-bag | Medium | You are given an integer array nums where the i^th bag contains nums[i] balls. You are also given an integer maxOperations.
You can perform the following operation at most maxOperations times:
- Take any bag of balls and divide it into two new bags with a positive number of balls.
- For example, a bag of 5 balls ca... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],maxOperations = 10) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],maxOperations = 9) == 5\n assert candidate(nums = [1000000000],maxOperations = 1) == 500000000\n assert candidate(nums = [1... | [
"[9]\n2",
"[2,4,8,2]\n4"
] | [
"Let's change the question if we know the maximum size of a bag what is the minimum number of bags you can make",
"note that as the maximum size increases the minimum number of bags decreases so we can binary search the maximum size"
] | {
"canonical_parameter_names": [
"nums",
"maxOperations"
],
"leetcode_dataset_entry_point": "Solution().minimumSize",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:29:53",
"tests_tota... | typescript | {
"raw_signature": "function minimumSize(nums: number[], maxOperations: number): number {",
"container": null,
"callable": "minimumSize",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "maxOperations",
"type": "number"
}
],
"return_type": "number",
... |
1,761 | minimum-degree-of-a-connected-trio-in-a-graph | Hard | You are given an undirected graph. You are given an integer n which is the number of nodes in the graph and an array edges, where each edges[i] = [u_i, v_i] indicates that there is an undirected edge between u_i and v_i.
A connected trio is a set of three nodes where there is an edge between every pair of them.
The d... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 4,edges = [[1, 2], [1, 3], [2, 3]]) == 0\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 3\n assert candidate(n = 400,edges = [[1, 2], [2, 3], [3, ... | [
"6\n[[1,2],[1,3],[3,2],[4,1],[5,2],[3,6]]",
"7\n[[1,3],[4,1],[4,3],[2,5],[5,6],[6,7],[7,5],[2,6]]"
] | [
"Consider a trio with nodes u, v, and w. The degree of the trio is just degree(u) + degree(v) + degree(w) - 6. The -6 comes from subtracting the edges u-v, u-w, and v-w, which are counted twice each in the vertex degree calculation.",
"To get the trios (u,v,w), you can iterate on u, then iterate on each w,v such ... | {
"canonical_parameter_names": [
"n",
"edges"
],
"leetcode_dataset_entry_point": "Solution().minTrioDegree",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:29:55",
"tests_total": 64,
... | typescript | {
"raw_signature": "function minTrioDegree(n: number, edges: number[][]): number {",
"container": null,
"callable": "minTrioDegree",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "edges",
"type": "number[][]"
}
],
"return_type": "number",
"signature_s... |
1,763 | longest-nice-substring | Easy | A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, "abABB" is nice because 'A' and 'a' appear, and 'B' and 'b' appear. However, "abA" is not because 'b' appears, but 'B' does not.
Given a string s, return the longest substring of s that is ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"Bb\") == \"Bb\"\n assert candidate(s = \"aAbBcCdDeEfFgG\") == \"aAbBcCdDeEfFgG\"\n ... | [
"\"YazaAay\"",
"\"Bb\"",
"\"c\""
] | [
"Brute force and check each substring to see if it is nice."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().longestNiceSubstring",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:00",
"tests_total": 152,
"tes... | typescript | {
"raw_signature": "function longestNiceSubstring(s: string): string {",
"container": null,
"callable": "longestNiceSubstring",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
1,764 | form-array-by-concatenating-subarrays-of-another-array | Medium | You are given a 2D integer array groups of length n. You are also given an integer array nums.
You are asked if you can choose n disjoint subarrays from the array nums such that the i^th subarray is equal to groups[i] (0-indexed), and if i > 0, the (i-1)^th subarray appears before the i^th subarray in nums (i.e. the s... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(groups = [[1, 2, 3]],nums = [1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2], [3, 4]],nums = [1, 2, 4, 3]) == False\n assert candidate(groups = [[5, 5, 5], [5]],nums = [5, 5, 5, 5]) == True\n assert candidate(grou... | [
"[[1,-1,-1],[3,-2,0]]\n[1,-1,0,1,-1,-1,3,-2,0]",
"[[10,-2],[1,2,3,4]]\n[1,2,3,4,10,-2]",
"[[1,2,3],[3,4]]\n[7,7,1,2,3,4,7,7]"
] | [
"When we use a subarray, the room for the next subarrays will be the suffix after the used subarray.",
"If we can match a group with multiple subarrays, we should choose the first one, as this will just leave the largest room for the next subarrays."
] | {
"canonical_parameter_names": [
"groups",
"nums"
],
"leetcode_dataset_entry_point": "Solution().canChoose",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:02",
"tests_total": 148,
... | typescript | {
"raw_signature": "function canChoose(groups: number[][], nums: number[]): boolean {",
"container": null,
"callable": "canChoose",
"parameters": [
{
"name": "groups",
"type": "number[][]"
},
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "boolean",
"signa... |
1,765 | map-of-highest-peak | Medium | You are given an integer matrix isWater of size m x n that represents a map of land and water cells.
- If isWater[i][j] == 0, cell (i, j) is a land cell.
- If isWater[i][j] == 1, cell (i, j) is a water cell.
You must assign each cell a height in a way that follows these rules:
- The height of each cell must be non-n... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(isWater = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == [[2, 1, 2], [1, 0, 1], [2, 1, 2]]\n assert candidate(isWater = [[0, 1], [0, 0]]) == [[1, 0], [2, 1]]\n assert candidate(isWater = [[1, 1], [1, 1]]) == [[0, 0], [0, 0]]\n assert can... | [
"[[0,1],[0,0]]",
"[[0,0,1],[1,0,0],[0,0,0]]"
] | [
"Set each water cell to be 0. The height of each cell is limited by its closest water cell.",
"Perform a multi-source BFS with all the water cells as sources."
] | {
"canonical_parameter_names": [
"isWater"
],
"leetcode_dataset_entry_point": "Solution().highestPeak",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:04",
"tests_total": 68,
"tests_d... | typescript | {
"raw_signature": "function highestPeak(isWater: number[][]): number[][] {",
"container": null,
"callable": "highestPeak",
"parameters": [
{
"name": "isWater",
"type": "number[][]"
}
],
"return_type": "number[][]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcod... |
1,766 | tree-of-coprimes | Hard | There is a tree (i.e., a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. Each node has a value associated with it, and the root of the tree is node 0.
To represent this tree, you are given an integer array nums and a 2D array edges. Each nums[i] r... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [2, 3, 3, 2],edges = [[0, 1], [1, 2], [1, 3]]) == [-1, 0, 0, 1]\n assert candidate(nums = [5, 6, 10, 2, 3, 6, 15],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == [-1, 0, -1, 0, 0, 0, -1]\n assert candidate(nums ... | [
"[2,3,3,2]\n[[0,1],[1,2],[1,3]]",
"[5,6,10,2,3,6,15]\n[[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]]"
] | [
"Note that for a node, it's not optimal to consider two nodes with the same value.",
"Note that the values are small enough for you to iterate over them instead of iterating over the parent nodes."
] | {
"canonical_parameter_names": [
"nums",
"edges"
],
"leetcode_dataset_entry_point": "Solution().getCoprimes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:06",
"tests_total": 31,
... | typescript | {
"raw_signature": "function getCoprimes(nums: number[], edges: number[][]): number[] {",
"container": null,
"callable": "getCoprimes",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "edges",
"type": "number[][]"
}
],
"return_type": "number[]",
"s... |
1,768 | merge-strings-alternately | Easy | You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string.
Return the merged string.
Example 1:
Input: word1 = "abc", word2 = "pqr"
Output: "apbqcr"
Ex... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word1 = \"a\",word2 = \"b\") == \"ab\"\n assert candidate(word1 = \"abcd\",word2 = \"pq\") == \"apbqcd\"\n assert candidate(word1 = \"ab\",word2 = \"pqrs\") == \"apbqrs\"\n assert candidate(word1 = \"x\",word2 = \"y\") == \"xy\"... | [
"\"abc\"\n\"pqr\"",
"\"ab\"\n\"pqrs\"",
"\"abcd\"\n\"pq\""
] | [
"Use two pointers, one pointer for each string. Alternately choose the character from each pointer, and move the pointer upwards."
] | {
"canonical_parameter_names": [
"word1",
"word2"
],
"leetcode_dataset_entry_point": "Solution().mergeAlternately",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:09",
"tests_total"... | typescript | {
"raw_signature": "function mergeAlternately(word1: string, word2: string): string {",
"container": null,
"callable": "mergeAlternately",
"parameters": [
{
"name": "word1",
"type": "string"
},
{
"name": "word2",
"type": "string"
}
],
"return_type": "string",
"signa... |
1,769 | minimum-number-of-operations-to-move-all-balls-to-each-box | Medium | You have n boxes. You are given a binary string boxes of length n, where boxes[i] is '0' if the i^th box is empty, and '1' if it contains one ball.
In one operation, you can move one ball from a box to an adjacent box. Box i is adjacent to box j if abs(i - j) == 1. Note that after doing so, there may be more than one ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(boxes = \"0101010101\") == [25, 20, 17, 14, 13, 12, 13, 14, 17, 20]\n assert candidate(boxes = \"001011\") == [11, 8, 5, 4, 3, 4]\n assert candidate(boxes = \"000111000\") == [12, 9, 6, 3, 2, 3, 6, 9, 12]\n assert candidate(boxe... | [
"\"110\"",
"\"001011\""
] | [
"If you want to move a ball from box i to box j, you'll need abs(i-j) moves.",
"To move all balls to some box, you can move them one by one.",
"For each box i, iterate on each ball in a box j, and add abs(i-j) to answers[i]."
] | {
"canonical_parameter_names": [
"boxes"
],
"leetcode_dataset_entry_point": "Solution().minOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:11",
"tests_total": 85,
"tests_d... | typescript | {
"raw_signature": "function minOperations(boxes: string): number[] {",
"container": null,
"callable": "minOperations",
"parameters": [
{
"name": "boxes",
"type": "string"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
1,770 | maximum-score-from-performing-multiplication-operations | Hard | You are given two 0-indexed integer arrays nums and multipliers of size n and m respectively, where n >= m.
You begin with a score of 0. You want to perform exactly m operations. On the i^th operation (0-indexed) you will:
- Choose one integer x from either the start or the end of the array nums.
- Add multipliers[i]... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 385\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],multipliers = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 385\n asse... | [
"[1,2,3]\n[3,2,1]",
"[-5,-3,-3,-2,7,1]\n[-10,-5,3,4,6]"
] | [
"At first glance, the solution seems to be greedy, but if you try to greedily take the largest value from the beginning or the end, this will not be optimal.",
"You should try all scenarios but this will be costly.",
"Memoizing the pre-visited states while trying all the possible scenarios will reduce the compl... | {
"canonical_parameter_names": [
"nums",
"multipliers"
],
"leetcode_dataset_entry_point": "Solution().maximumScore",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:13",
"tests_total... | typescript | {
"raw_signature": "function maximumScore(nums: number[], multipliers: number[]): number {",
"container": null,
"callable": "maximumScore",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "multipliers",
"type": "number[]"
}
],
"return_type": "number"... |
1,771 | maximize-palindrome-length-from-subsequences | Hard | You are given two strings, word1 and word2. You want to construct a string in the following manner:
- Choose some non-empty subsequence subsequence1 from word1.
- Choose some non-empty subsequence subsequence2 from word2.
- Concatenate the subsequences: subsequence1 + subsequence2, to make the string.
Return the leng... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word1 = \"race\",word2 = \"car\") == 7\n assert candidate(word1 = \"a\",word2 = \"a\") == 2\n assert candidate(word1 = \"aabb\",word2 = \"bbcc\") == 4\n assert candidate(word1 = \"race\",word2 = \"care\") == 7\n assert candid... | [
"\"cacb\"\n\"cbba\"",
"\"ab\"\n\"ab\"",
"\"aa\"\n\"bb\""
] | [
"Let's ignore the non-empty subsequence constraint. We can concatenate the two strings and find the largest palindromic subsequence with dynamic programming.",
"Iterate through every pair of characters word1[i] and word2[j], and see if some palindrome begins with word1[i] and ends with word2[j]. This ensures that... | {
"canonical_parameter_names": [
"word1",
"word2"
],
"leetcode_dataset_entry_point": "Solution().longestPalindrome",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:16",
"tests_total... | typescript | {
"raw_signature": "function longestPalindrome(word1: string, word2: string): number {",
"container": null,
"callable": "longestPalindrome",
"parameters": [
{
"name": "word1",
"type": "string"
},
{
"name": "word2",
"type": "string"
}
],
"return_type": "number",
"sig... |
1,773 | count-items-matching-a-rule | Easy | You are given an array items, where each items[i] = [type_i, color_i, name_i] describes the type, color, and name of the i^th item. You are also given a rule represented by two strings, ruleKey and ruleValue.
The i^th item is said to match the rule if one of the following is true:
- ruleKey == "type" and ruleValue ==... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'harley'], ['car', 'green', 'lambo']],ruleKey = \"color\",ruleValue = \"red\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'phone'], ['phone'... | [
"[[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"lenovo\"],[\"phone\",\"gold\",\"iphone\"]]\n\"color\"\n\"silver\"",
"[[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"phone\"],[\"phone\",\"gold\",\"iphone\"]]\n\"type\"\n\"phone\""
] | [
"Iterate on each item, and check if each one matches the rule according to the statement."
] | {
"canonical_parameter_names": [
"items",
"ruleKey",
"ruleValue"
],
"leetcode_dataset_entry_point": "Solution().countMatches",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:20",
... | typescript | {
"raw_signature": "function countMatches(items: string[][], ruleKey: string, ruleValue: string): number {",
"container": null,
"callable": "countMatches",
"parameters": [
{
"name": "items",
"type": "string[][]"
},
{
"name": "ruleKey",
"type": "string"
},
{
"nam... |
1,774 | closest-dessert-cost | Medium | You would like to make dessert and are preparing to buy the ingredients. You have n ice cream base flavors and m types of toppings to choose from. You must follow these rules when making your dessert:
- There must be exactly one ice cream base.
- You can add one or more types of topping or have no toppings at all.
- T... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(baseCosts = [10, 20],toppingCosts = [1, 2, 3],target = 15) == 15\n assert candidate(baseCosts = [5, 9],toppingCosts = [2, 3, 7],target = 15) == 15\n assert candidate(baseCosts = [1, 7],toppingCosts = [3, 4],target = 10) == 10\n ... | [
"[1,7]\n[3,4]\n10",
"[2,3]\n[4,5,100]\n18",
"[3,10]\n[2,5]\n9"
] | [
"As the constraints are not large, you can brute force and enumerate all the possibilities."
] | {
"canonical_parameter_names": [
"baseCosts",
"toppingCosts",
"target"
],
"leetcode_dataset_entry_point": "Solution().closestCost",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:... | typescript | {
"raw_signature": "function closestCost(baseCosts: number[], toppingCosts: number[], target: number): number {",
"container": null,
"callable": "closestCost",
"parameters": [
{
"name": "baseCosts",
"type": "number[]"
},
{
"name": "toppingCosts",
"type": "number[]"
},
... |
1,775 | equal-sum-arrays-with-minimum-number-of-operations | Medium | You are given two arrays of integers nums1 and nums2, possibly of different lengths. The values in the arrays are between 1 and 6, inclusive.
In one operation, you can change any integer's value in any of the arrays to any value between 1 and 6, inclusive.
Return the minimum number of operations required to make the ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums1 = [6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [3, 3, 3, 3],nums2 = [2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1, 1],nums2 = [6, 6]) == 2\n assert candidate(nums1 = [6, 6, 6],nums2 = [... | [
"[1,2,3,4,5,6]\n[1,1,2,2,2,2]",
"[1,1,1,1,1,1,1]\n[6]",
"[6,6]\n[1]"
] | [
"Let's note that we want to either decrease the sum of the array with a larger sum or increase the array's sum with the smaller sum.",
"You can maintain the largest increase or decrease you can make in a binary search tree and each time get the maximum one."
] | {
"canonical_parameter_names": [
"nums1",
"nums2"
],
"leetcode_dataset_entry_point": "Solution().minOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:25",
"tests_total": 1... | typescript | {
"raw_signature": "function minOperations(nums1: number[], nums2: number[]): number {",
"container": null,
"callable": "minOperations",
"parameters": [
{
"name": "nums1",
"type": "number[]"
},
{
"name": "nums2",
"type": "number[]"
}
],
"return_type": "number",
"sig... |
1,776 | car-fleet-ii | Hard | There are n cars traveling at different speeds in the same direction along a one-lane road. You are given an array cars of length n, where cars[i] = [position_i, speed_i] represents:
- position_i is the distance between the i^th car and the beginning of the road in meters. It is guaranteed that position_i < position_{... | {
"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... | [
"[[1,2],[2,1],[4,3],[7,2]]",
"[[3,4],[5,4],[6,3],[9,1]]"
] | [
"We can simply ignore the merging of any car fleet, simply assume they cross each other. Now the aim is to find the first car to the right, which intersects with the current car before any other.",
"Assume we have already considered all cars to the right already, now the current car is to be considered. Let’s ign... | {
"canonical_parameter_names": [
"cars"
],
"leetcode_dataset_entry_point": "Solution().getCollisionTimes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:28",
"tests_total": 95,
"test... | typescript | {
"raw_signature": "function getCollisionTimes(cars: number[][]): number[] {",
"container": null,
"callable": "getCollisionTimes",
"parameters": [
{
"name": "cars",
"type": "number[][]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetc... |
1,779 | find-nearest-point-that-has-the-same-x-or-y-coordinate | Easy | You are given two integers, x and y, which represent your current location on a Cartesian grid: (x, y). You are also given an array points where each points[i] = [a_i, b_i] represents that a point exists at (a_i, b_i). A point is valid if it shares the same x-coordinate or the same y-coordinate as your location.
Retur... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(x = 3,y = 4,points = [[3, 4]]) == 0\n assert candidate(x = 5,y = 5,points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4]]) == 3\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4]]) == -1\n assert ... | [
"3\n4\n[[1,2],[3,1],[2,4],[2,3],[4,4]]",
"3\n4\n[[3,4]]",
"3\n4\n[[2,3]]"
] | [
"Iterate through each point, and keep track of the current point with the smallest Manhattan distance from your current location."
] | {
"canonical_parameter_names": [
"x",
"y",
"points"
],
"leetcode_dataset_entry_point": "Solution().nearestValidPoint",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:30",
"tests... | typescript | {
"raw_signature": "function nearestValidPoint(x: number, y: number, points: number[][]): number {",
"container": null,
"callable": "nearestValidPoint",
"parameters": [
{
"name": "x",
"type": "number"
},
{
"name": "y",
"type": "number"
},
{
"name": "points",
... |
1,780 | check-if-number-is-a-sum-of-powers-of-three | Medium | Given an integer n, return true if it is possible to represent n as the sum of distinct powers of three. Otherwise, return false.
An integer y is a power of three if there exists an integer x such that y == 3^x.
Example 1:
Input: n = 12
Output: true
Explanation: 12 = 3^1 + 3^2
Example 2:
Input: n = 91
Output: true... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 59049) == True\n assert candidate(n = 3) == True\n assert candidate(n = 729) == True\n assert candidate(n = 12) == True\n assert candidate(n = 243) == True\n assert candidate(n = 21) == False\n assert candidate(n = ... | [
"12",
"91",
"21"
] | [
"Let's note that the maximum power of 3 you'll use in your soln is 3^16",
"The number can not be represented as a sum of powers of 3 if it's ternary presentation has a 2 in it"
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().checkPowersOfThree",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:33",
"tests_total": 110,
"tests... | typescript | {
"raw_signature": "function checkPowersOfThree(n: number): boolean {",
"container": null,
"callable": "checkPowersOfThree",
"parameters": [
{
"name": "n",
"type": "number"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
1,781 | sum-of-beauty-of-all-substrings | Medium | The beauty of a string is the difference in frequencies between the most frequent and least frequent characters.
- For example, the beauty of "abaacc" is 3 - 1 = 2.
Given a string s, return the sum of beauty of all of its substrings.
Example 1:
Input: s = "aabcb"
Output: 5
Explanation: The substrings with non-zero ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"xyzzxyzzxyzz\") == 87\n assert candidate(s = \"aaabbbccc\") == 29\n assert candidate(s = \"aabcb\") == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(s = \"abcdedcba\") == 16\n asser... | [
"\"aabcb\"",
"\"aabcbaa\""
] | [
"Maintain a prefix sum for the frequencies of characters.",
"You can iterate over all substring then iterate over the alphabet and find which character appears most and which appears least using the prefix sum array"
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().beautySum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:35",
"tests_total": 103,
"tests_dropped"... | typescript | {
"raw_signature": "function beautySum(s: string): number {",
"container": null,
"callable": "beautySum",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,782 | count-pairs-of-nodes | Hard | You are given an undirected graph defined by an integer n, the number of nodes, and a 2D integer array edges, the edges in the graph, where edges[i] = [u_i, v_i] indicates that there is an undirected edge between u_i and v_i. You are also given an integer array queries.
Let incident(a, b) be defined as the number of e... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 4,edges = [[1, 2], [2, 4], [1, 3], [2, 3], [2, 1]],queries = [2, 3]) == [6, 5]\n assert candidate(n = 5,edges = [[1, 5], [1, 5], [3, 4], [2, 5], [1, 3], [5, 1], [2, 3], [2, 5]],queries = [1, 2, 3, 4, 5]) == [10, 10, 9, 8, 6]\n ... | [
"4\n[[1,2],[2,4],[1,3],[2,3],[2,1]]\n[2,3]",
"5\n[[1,5],[1,5],[3,4],[2,5],[1,3],[5,1],[2,3],[2,5]]\n[1,2,3,4,5]"
] | [
"We want to count pairs (x,y) such that degree[x] + degree[y] - occurrences(x,y) > k",
"Think about iterating on x, and counting the number of valid y to pair with x.",
"You can consider at first that the (- occurrences(x,y)) isn't there, or it is 0 at first for all y. Count the valid y this way.",
"Then you ... | {
"canonical_parameter_names": [
"n",
"edges",
"queries"
],
"leetcode_dataset_entry_point": "Solution().countPairs",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:37",
"tests_t... | typescript | {
"raw_signature": "function countPairs(n: number, edges: number[][], queries: number[]): number[] {",
"container": null,
"callable": "countPairs",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "edges",
"type": "number[][]"
},
{
"name": "queries",... |
1,784 | check-if-binary-string-has-at-most-one-segment-of-ones | Easy | Given a binary string s without leading zeros, return true if s contains at most one contiguous segment of ones. Otherwise, return false.
Example 1:
Input: s = "1001"
Output: false
Explanation: The string has two segments of size 1.
Example 2:
Input: s = "110"
Output: true
Constraints:
- 1 <= s.length <= 100
- s[... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"1111\") == True\n assert candidate(s = \"1000001\") == False\n assert candidate(s = \"111\") == True\n assert candidate(s = \"11110000\") == True\n assert candidate(s = \"100000\") == True\n assert candidate(s = \"11... | [
"\"1001\"",
"\"110\""
] | [
"It's guaranteed to have at least one segment",
"The string size is small so you can count all segments of ones with no that have no adjacent ones."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().checkOnesSegment",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:40",
"tests_total": 113,
"tests_d... | typescript | {
"raw_signature": "function checkOnesSegment(s: string): boolean {",
"container": null,
"callable": "checkOnesSegment",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
1,785 | minimum-elements-to-add-to-form-a-given-sum | Medium | You are given an integer array nums and two integers limit and goal. The array nums has an interesting property that abs(nums[i]) <= limit.
Return the minimum number of elements you need to add to make the sum of the array equal to goal. The array must maintain its property that abs(nums[i]) <= limit.
Note that abs(x... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, -1, 1],limit = 3,goal = -4) == 2\n assert candidate(nums = [1, -10, 9, 1],limit = 100,goal = 0) == 1\n assert candidate(nums = [0, 0, 0],limit = 1,goal = 3) == 3\n assert candidate(nums = [0, 0, 0, 0],limit = 5,goal =... | [
"[1,-1,1]\n3\n-4",
"[1,-10,9,1]\n100\n0"
] | [
"Try thinking about the problem as if the array is empty. Then you only need to form goal using elements whose absolute value is <= limit.",
"You can greedily set all of the elements except one to limit or -limit, so the number of elements you need is ceil(abs(goal)/ limit).",
"You can \"normalize\" goal by off... | {
"canonical_parameter_names": [
"nums",
"limit",
"goal"
],
"leetcode_dataset_entry_point": "Solution().minElements",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:42",
"tests_... | typescript | {
"raw_signature": "function minElements(nums: number[], limit: number, goal: number): number {",
"container": null,
"callable": "minElements",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "limit",
"type": "number"
},
{
"name": "goal",
... |
1,786 | number-of-restricted-paths-from-first-to-last-node | Medium | There is an undirected weighted connected graph. You are given a positive integer n which denotes that the graph has n nodes labeled from 1 to n, and an array edges where each edges[i] = [u_i, v_i, weight_i] denotes that there is an edge between nodes u_i and v_i with weight equal to weight_i.
A path from node start t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 4,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 1, 4]]) == 1\n assert candidate(n = 3,edges = [[1, 2, 5], [1, 3, 6], [2, 3, 1]]) == 2\n assert candidate(n = 7,edges = [[1, 3, 1], [4, 1, 2], [7, 3, 4], [2, 5, 3], [5, 6, 1], [6, ... | [
"5\n[[1,2,3],[1,3,3],[2,3,1],[1,4,2],[5,2,2],[3,5,1],[5,4,10]]",
"7\n[[1,3,1],[4,1,2],[7,3,4],[2,5,3],[5,6,1],[6,7,2],[7,5,3],[2,6,4]]"
] | [
"Run a Dijkstra from node numbered n to compute distance from the last node.",
"Consider all edges [u, v] one by one and direct them such that distance of u to n > distance of v to n. If both u and v are at the same distance from n, discard this edge.",
"Now this problem reduces to computing the number of paths... | {
"canonical_parameter_names": [
"n",
"edges"
],
"leetcode_dataset_entry_point": "Solution().countRestrictedPaths",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:45",
"tests_total"... | typescript | {
"raw_signature": "function countRestrictedPaths(n: number, edges: number[][]): number {",
"container": null,
"callable": "countRestrictedPaths",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "edges",
"type": "number[][]"
}
],
"return_type": "number",
... |
1,787 | make-the-xor-of-all-segments-equal-to-zero | Hard | You are given an array nums and an integer k. The XOR of a segment [left, right] where left <= right is the XOR of all the elements with indices between left and right, inclusive: nums[left] XOR nums[left+1] XOR ... XOR nums[right].
Return the minimum number of elements to change in the array such that the XOR of all ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 0\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 5) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],k = 5) == 1\n assert candidate(nums = [1, 3, 5, 7, 9... | [
"[1,2,0,3,0]\n1",
"[3,4,5,2,1,7,3,4,7]\n3",
"[1,2,4,1,2,5,1,2,6]\n3"
] | [
"Let's note that for the XOR of all segments with size K to be equal to zeros, nums[i] has to be equal to nums[i+k]",
"Basically, we need to make the first K elements have XOR = 0 and then modify them."
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().minChanges",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:47",
"tests_total": 113,
"t... | typescript | {
"raw_signature": "function minChanges(nums: number[], k: number): number {",
"container": null,
"callable": "minChanges",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "lee... |
1,790 | check-if-one-string-swap-can-make-strings-equal | Easy | You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices.
Return true if it is possible to make both strings equal by performing at most one string swap on exactly one of the strings.... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s1 = \"attack\",s2 = \"defend\") == False\n assert candidate(s1 = \"bank\",s2 = \"kanb\") == True\n assert candidate(s1 = \"abcde\",s2 = \"abced\") == True\n assert candidate(s1 = \"abcd\",s2 = \"abdc\") == True\n assert cand... | [
"\"bank\"\n\"kanb\"",
"\"attack\"\n\"defend\"",
"\"kelb\"\n\"kelb\""
] | [
"The answer is false if the number of nonequal positions in the strings is not equal to 0 or 2.",
"Check that these positions have the same set of characters."
] | {
"canonical_parameter_names": [
"s1",
"s2"
],
"leetcode_dataset_entry_point": "Solution().areAlmostEqual",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:52",
"tests_total": 108,
... | typescript | {
"raw_signature": "function areAlmostEqual(s1: string, s2: string): boolean {",
"container": null,
"callable": "areAlmostEqual",
"parameters": [
{
"name": "s1",
"type": "string"
},
{
"name": "s2",
"type": "string"
}
],
"return_type": "boolean",
"signature_source": ... |
1,791 | find-center-of-star-graph | Easy | There is an undirected star graph consisting of n nodes labeled from 1 to n. A star graph is a graph where there is one center node and exactly n - 1 edges that connect the center node with every other node.
You are given a 2D integer array edges where each edges[i] = [u_i, v_i] indicates that there is an edge between... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(edges = [[3, 1], [1, 2], [1, 4], [1, 5]]) == 1\n assert candidate(edges = [[7, 3], [7, 4], [7, 2], [7, 5], [7, 6], [7, 1]]) == 7\n assert candidate(edges = [[4, 3], [5, 3], [2, 3], [1, 3]]) == 3\n assert candidate(edges = [[1, 2... | [
"[[1,2],[2,3],[4,2]]",
"[[1,2],[5,1],[1,3],[1,4]]"
] | [
"The center is the only node that has more than one edge.",
"The center is also connected to all other nodes.",
"Any two edges must have a common node, which is the center."
] | {
"canonical_parameter_names": [
"edges"
],
"leetcode_dataset_entry_point": "Solution().findCenter",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:54",
"tests_total": 58,
"tests_drop... | typescript | {
"raw_signature": "function findCenter(edges: number[][]): number {",
"container": null,
"callable": "findCenter",
"parameters": [
{
"name": "edges",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
1,792 | maximum-average-pass-ratio | Medium | There is a school that has classes of students and each class will be having a final exam. You are given a 2D integer array classes, where classes[i] = [pass_i, total_i]. You know beforehand that in the i^th class, there are total_i total students, but only pass_i number of students will pass the exam.
You are also gi... | {
"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... | [
"[[1,2],[3,5],[2,2]]\n2",
"[[2,4],[3,9],[4,5],[2,10]]\n4"
] | [
"Pay attention to how much the pass ratio changes when you add a student to the class. If you keep adding students, what happens to the change in pass ratio? The more students you add to a class, the smaller the change in pass ratio becomes.",
"Since the change in the pass ratio is always decreasing with the more... | {
"canonical_parameter_names": [
"classes",
"extraStudents"
],
"leetcode_dataset_entry_point": "Solution().maxAverageRatio",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:57",
"tes... | typescript | {
"raw_signature": "function maxAverageRatio(classes: number[][], extraStudents: number): number {",
"container": null,
"callable": "maxAverageRatio",
"parameters": [
{
"name": "classes",
"type": "number[][]"
},
{
"name": "extraStudents",
"type": "number"
}
],
"return... |
1,793 | maximum-score-of-a-good-subarray | Hard | You are given an array of integers nums (0-indexed) and an integer k.
The score of a subarray (i, j) is defined as min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1). A good subarray is a subarray where i <= k <= j.
Return the maximum possible score of a good subarray.
Example 1:
Input: nums = [1,4,3,7,4,5], k = 3... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 5, 4, 5, 4, 1, 1, 1],k = 0) == 20\n assert candidate(nums = [10, 10, 10, 10, 10],k = 2) == 50\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 25\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 10... | [
"[1,4,3,7,4,5]\n3",
"[5,5,4,5,4,1,1,1]\n0"
] | [
"Try thinking about the prefix before index k and the suffix after index k as two separate arrays.",
"Using two pointers or binary search, we can find the maximum prefix of each array where the numbers are less than or equal to a certain value"
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().maximumScore",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:30:59",
"tests_total": 98,
"... | typescript | {
"raw_signature": "function maximumScore(nums: number[], k: number): number {",
"container": null,
"callable": "maximumScore",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": ... |
1,796 | second-largest-digit-in-a-string | Easy | Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist.
An alphanumeric string is a string consisting of lowercase English letters and digits.
Example 1:
Input: s = "dfa12321afd"
Output: 2
Explanation: The digits that appear in s are [1, 2, 3]. The sec... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"9876543210\") == 8\n assert candidate(s = \"same1same1same1\") == -1\n assert candidate(s = \"abcdefghij0\") == -1\n assert candidate(s = \"abc1111\") == -1\n assert candidate(s = \"1a\") == -1\n assert candidate(s =... | [
"\"dfa12321afd\"",
"\"abc1111\""
] | [
"First of all, get the distinct characters since we are only interested in those",
"Let's note that there might not be any digits."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().secondHighest",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:04",
"tests_total": 131,
"tests_drop... | typescript | {
"raw_signature": "function secondHighest(s: string): number {",
"container": null,
"callable": "secondHighest",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,798 | maximum-number-of-consecutive-values-you-can-make | Medium | You are given an integer array coins of length n which represents the n coins that you own. The value of the i^th coin is coins[i]. You can make some value x if you can choose some of your n coins such that their values sum up to x.
Return the maximum number of consecutive integer values that you can make with your co... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(coins = [1, 3]) == 2\n assert candidate(coins = [1, 2, 5]) == 4\n assert candidate(coins = [2, 2, 2, 2]) == 1\n assert candidate(coins = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 56\n assert candidate(coins = [1]) == 2\n assert ... | [
"[1,3]",
"[1,1,1,4]",
"[1,4,10,3,1]"
] | [
"If you can make the first x values and you have a value v, then you can make all the values ≤ v + x",
"Sort the array of coins. You can always make the value 0 so you can start with x = 0.",
"Process the values starting from the smallest and stop when there is a value that cannot be achieved with the current x... | {
"canonical_parameter_names": [
"coins"
],
"leetcode_dataset_entry_point": "Solution().getMaximumConsecutive",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:07",
"tests_total": 98,
... | typescript | {
"raw_signature": "function getMaximumConsecutive(coins: number[]): number {",
"container": null,
"callable": "getMaximumConsecutive",
"parameters": [
{
"name": "coins",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "lee... |
1,800 | maximum-ascending-subarray-sum | Easy | Given an array of positive integers nums, return the maximum possible sum of an strictly increasing subarray in nums.
A subarray is defined as a contiguous sequence of numbers in an array.
Example 1:
Input: nums = [10,20,30,5,10,50]
Output: 65
Explanation: [5,10,50] is the ascending subarray with the maximum sum of ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [100, 99, 98, 97, 96]) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [10]) == 10\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [100, 1, 2, 3, 100, 2, ... | [
"[10,20,30,5,10,50]",
"[10,20,30,40,50]",
"[12,17,15,13,10,11,12]"
] | [
"It is fast enough to check all possible subarrays",
"The end of each ascending subarray will be the start of the next"
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maxAscendingSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:09",
"tests_total": 128,
"tests... | typescript | {
"raw_signature": "function maxAscendingSum(nums: number[]): number {",
"container": null,
"callable": "maxAscendingSum",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
1,801 | number-of-orders-in-the-backlog | Medium | You are given a 2D integer array orders, where each orders[i] = [price_i, amount_i, orderType_i] denotes that amount_iorders have been placed of type orderType_i at the price price_i. The orderType_i is:
- 0 if it is a batch of buy orders, or
- 1 if it is a batch of sell orders.
Note that orders[i] represents a batch... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(orders = [[7, 1000000000, 1], [15, 3, 0], [5, 999999995, 0], [5, 1, 1]]) == 999999984\n assert candidate(orders = [[1, 10, 0], [1, 10, 1], [1, 10, 0], [1, 10, 1]]) == 0\n assert candidate(orders = [[100, 1, 0], [200, 2, 0], [300, 3... | [
"[[10,5,0],[15,2,1],[25,1,1],[30,4,0]]",
"[[7,1000000000,1],[15,3,0],[5,999999995,0],[5,1,1]]"
] | [
"Store the backlog buy and sell orders in two heaps, the buy orders in a max heap by price and the sell orders in a min heap by price.",
"Store the orders in batches and update the fields according to new incoming orders. Each batch should only take 1 \"slot\" in the heap."
] | {
"canonical_parameter_names": [
"orders"
],
"leetcode_dataset_entry_point": "Solution().getNumberOfBacklogOrders",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:11",
"tests_total": 11... | typescript | {
"raw_signature": "function getNumberOfBacklogOrders(orders: number[][]): number {",
"container": null,
"callable": "getNumberOfBacklogOrders",
"parameters": [
{
"name": "orders",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_s... |
1,802 | maximum-value-at-a-given-index-in-a-bounded-array | Medium | You are given three positive integers: n, index, and maxSum. You want to construct an array nums (0-indexed) that satisfies the following conditions:
- nums.length == n
- nums[i] is a positive integer where 0 <= i < n.
- abs(nums[i] - nums[i+1]) <= 1 where 0 <= i < n-1.
- The sum of all the elements of nums does not e... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 1,index = 0,maxSum = 1) == 1\n assert candidate(n = 10,index = 5,maxSum = 50) == 7\n assert candidate(n = 6,index = 1,maxSum = 10) == 3\n assert candidate(n = 1000000000,index = 500000000,maxSum = 1000000000) == 1\n asser... | [
"4\n2\n6",
"6\n1\n10"
] | [
"What if the problem was instead determining if you could generate a valid array with nums[index] == target?",
"To generate the array, set nums[index] to target, nums[index-i] to target-i, and nums[index+i] to target-i. Then, this will give the minimum possible sum, so check if the sum is less than or equal to ma... | {
"canonical_parameter_names": [
"n",
"index",
"maxSum"
],
"leetcode_dataset_entry_point": "Solution().maxValue",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:14",
"tests_tota... | typescript | {
"raw_signature": "function maxValue(n: number, index: number, maxSum: number): number {",
"container": null,
"callable": "maxValue",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "index",
"type": "number"
},
{
"name": "maxSum",
"type": "nu... |
1,803 | count-pairs-with-xor-in-a-range | Hard | Given a (0-indexed) integer array nums and two integers low and high, return the number of nice pairs.
A nice pair is a pair (i, j) where 0 <= i < j < nums.length and low <= (nums[i] XOR nums[j]) <= high.
Example 1:
Input: nums = [1,4,2,7], low = 2, high = 6
Output: 6
Explanation: All nice pairs (i, j) are as follow... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 7, 9],low = 1,high = 10) == 8\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9],low = 3,high = 7) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],low = 15,high = 25) == 1\n assert candidate(nums = [9, 8, 4... | [
"[1,4,2,7]\n2\n6",
"[9,8,4,2,1]\n5\n14"
] | [
"Let's note that we can count all pairs with XOR ≤ K, so the answer would be to subtract the number of pairs withs XOR < low from the number of pairs with XOR ≤ high.",
"For each value, find out the number of values when you XOR it with the result is ≤ K using a trie."
] | {
"canonical_parameter_names": [
"nums",
"low",
"high"
],
"leetcode_dataset_entry_point": "Solution().countPairs",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:16",
"tests_tot... | typescript | {
"raw_signature": "function countPairs(nums: number[], low: number, high: number): number {",
"container": null,
"callable": "countPairs",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "low",
"type": "number"
},
{
"name": "high",
"type... |
1,805 | number-of-different-integers-in-a-string | Easy | You are given a string word that consists of digits and lowercase English letters.
You will replace every non-digit character with a space. For example, "a123bc34d8ef34" will become " 123 34 8 34". Notice that you are left with some integers that are separated by at least one space: "123", "34", "8", and "34".
Return... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0\") == 10\n assert candidate(word = \"a123bc34d8ef34\") == 3\n assert candidate(word = \"a1a2a3a4a5a6a7a8a9a0\") == 10\n assert candidate(word = \"100leetcode\") == 1\n assert candidate(word = \"a... | [
"\"a123bc34d8ef34\"",
"\"leet1234code234\"",
"\"a1b01c001\""
] | [
"Try to split the string so that each integer is in a different string.",
"Try to remove each integer's leading zeroes and compare the strings to find how many of them are unique."
] | {
"canonical_parameter_names": [
"word"
],
"leetcode_dataset_entry_point": "Solution().numDifferentIntegers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:18",
"tests_total": 124,
"... | typescript | {
"raw_signature": "function numDifferentIntegers(word: string): number {",
"container": null,
"callable": "numDifferentIntegers",
"parameters": [
{
"name": "word",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
1,806 | minimum-number-of-operations-to-reinitialize-a-permutation | Medium | You are given an even integer n. You initially have a permutation perm of size n where perm[i] == i (0-indexed).
In one operation, you will create a new array arr, and for each i:
- If i % 2 == 0, then arr[i] = perm[i / 2].
- If i % 2 == 1, then arr[i] = perm[n / 2 + (i - 1) / 2].
You will then assign arr to perm.
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 8) == 3\n assert candidate(n = 4) == 2\n assert candidate(n = 12) == 10\n assert candidate(n = 14) == 12\n assert candidate(n = 16) == 4\n assert candidate(n = 18) == 8\n assert candidate(n = 6) == 4\n assert can... | [
"2",
"4",
"6"
] | [
"It is safe to assume the number of operations isn't more than n",
"The number is small enough to apply a brute force solution."
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().reinitializePermutation",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:20",
"tests_total": 38,
"t... | typescript | {
"raw_signature": "function reinitializePermutation(n: number): number {",
"container": null,
"callable": "reinitializePermutation",
"parameters": [
{
"name": "n",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
1,807 | evaluate-the-bracket-pairs-of-a-string | Medium | You are given a string s that contains some bracket pairs, with each pair containing a non-empty key.
- For example, in the string "(name)is(age)yearsold", there are two bracket pairs that contain the keys "name" and "age".
You know the values of a wide range of keys. This is represented by a 2D string array knowledg... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"(a)(a)(a)aaa\",knowledge = [['a', 'yes']]) == \"yesyesyesaaa\"\n assert candidate(s = \"hi(name)\",knowledge = [['a', 'b']]) == \"hi?\"\n assert candidate(s = \"(a)(a)(a)aaa\",knowledge = [['a', 'yes']]) == \"yesyesyesaaa\"\n... | [
"\"(name)is(age)yearsold\"\n[[\"name\",\"bob\"],[\"age\",\"two\"]]",
"\"hi(name)\"\n[[\"a\",\"b\"]]",
"\"(a)(a)(a)aaa\"\n[[\"a\",\"yes\"]]"
] | [
"Process pairs from right to left to handle repeats",
"Keep track of the current enclosed string using another string"
] | {
"canonical_parameter_names": [
"s",
"knowledge"
],
"leetcode_dataset_entry_point": "Solution().evaluate",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:23",
"tests_total": 113,
... | typescript | {
"raw_signature": "function evaluate(s: string, knowledge: string[][]): string {",
"container": null,
"callable": "evaluate",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "knowledge",
"type": "string[][]"
}
],
"return_type": "string",
"signature_sou... |
1,812 | determine-color-of-a-chessboard-square | Easy | You are given coordinates, a string that represents the coordinates of a square of the chessboard. Below is a chessboard for your reference.
Return true if the square is white, and false if the square is black.
The coordinate will always represent a valid chessboard square. The coordinate will always have the letter ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(coordinates = \"d5\") == True\n assert candidate(coordinates = \"e4\") == True\n assert candidate(coordinates = \"b8\") == False\n assert candidate(coordinates = \"b2\") == False\n assert candidate(coordinates = \"a1\") == Fa... | [
"\"a1\"",
"\"h3\"",
"\"c7\""
] | [
"Convert the coordinates to (x, y) - that is, \"a1\" is (1, 1), \"d7\" is (4, 7).",
"Try add the numbers together and look for a pattern."
] | {
"canonical_parameter_names": [
"coordinates"
],
"leetcode_dataset_entry_point": "Solution().squareIsWhite",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:27",
"tests_total": 74,
"t... | typescript | {
"raw_signature": "function squareIsWhite(coordinates: string): boolean {",
"container": null,
"callable": "squareIsWhite",
"parameters": [
{
"name": "coordinates",
"type": "string"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
1,813 | sentence-similarity-iii | Medium | You are given two strings sentence1 and sentence2, each representing a sentence composed of words. A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of only uppercase and lowercase English characters.
Two sentences s1 and s2 are considered similar... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Similar similar sentences\") == True\n assert candidate(sentence1 = \"Start end\",sentence2 = \"Start middle end\") == True\n assert candidate(sentence1 = \"Eating right now\",sentenc... | [
"\"My name is Haley\"\n\"My Haley\"",
"\"of\"\n\"A lot of words\"",
"\"Eating right now\"\n\"Eating\""
] | [
"One way to look at it is to find one sentence as a concatenation of a prefix and suffix from the other sentence.",
"Get the longest common prefix between them and the longest common suffix."
] | {
"canonical_parameter_names": [
"sentence1",
"sentence2"
],
"leetcode_dataset_entry_point": "Solution().areSentencesSimilar",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:29",
"t... | typescript | {
"raw_signature": "function areSentencesSimilar(sentence1: string, sentence2: string): boolean {",
"container": null,
"callable": "areSentencesSimilar",
"parameters": [
{
"name": "sentence1",
"type": "string"
},
{
"name": "sentence2",
"type": "string"
}
],
"return_ty... |
1,814 | count-nice-pairs-in-an-array | Medium | You are given an array nums that consists of non-negative integers. Let us define rev(x) as the reverse of the non-negative integer x. For example, rev(123) = 321, and rev(120) = 21. A pair of indices (i, j) is nice if it satisfies all of the following conditions:
- 0 <= i < j < nums.length
- nums[i] + rev(nums[j]) ==... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 45\n assert candidate(nums = [100, 200, 300, 400]) == 0\n assert candidate(nums = [123, 321, 213, 132, 231, 312]) == 2\n assert candidate(nums = [123, 321, 213, 132]) == 1\n assert ca... | [
"[42,11,1,97]",
"[13,10,35,24,76]"
] | [
"The condition can be rearranged to (nums[i] - rev(nums[i])) == (nums[j] - rev(nums[j])).",
"Transform each nums[i] into (nums[i] - rev(nums[i])). Then, count the number of (i, j) pairs that have equal values.",
"Keep a map storing the frequencies of values that you have seen so far. For each i, check if nums[i... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countNicePairs",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:32",
"tests_total": 107,
"tests_... | typescript | {
"raw_signature": "function countNicePairs(nums: number[]): number {",
"container": null,
"callable": "countNicePairs",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
1,815 | maximum-number-of-groups-getting-fresh-donuts | Hard | There is a donuts shop that bakes donuts in batches of batchSize. They have a rule where they must serve all of the donuts of a batch before serving any donuts of the next batch. You are given an integer batchSize and an integer array groups, where groups[i] denotes that there is a group of groups[i] customers that wil... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49]) == 7\n assert candidate(batchSize = 2,groups = [2, 2, 2, 2, 2, 2]) == 6\n assert candidate(batchSize = 7,groups = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 12\n assert candidate... | [
"3\n[1,2,3,4,5,6]",
"4\n[1,3,2,5,2,2,1,6]"
] | [
"The maximum number of happy groups is the maximum number of partitions you can split the groups into such that the sum of group sizes in each partition is 0 mod batchSize. At most one partition is allowed to have a different remainder (the first group will get fresh donuts anyway).",
"Suppose you have an array f... | {
"canonical_parameter_names": [
"batchSize",
"groups"
],
"leetcode_dataset_entry_point": "Solution().maxHappyGroups",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:34",
"tests_tot... | typescript | {
"raw_signature": "function maxHappyGroups(batchSize: number, groups: number[]): number {",
"container": null,
"callable": "maxHappyGroups",
"parameters": [
{
"name": "batchSize",
"type": "number"
},
{
"name": "groups",
"type": "number[]"
}
],
"return_type": "number"... |
1,816 | truncate-sentence | Easy | A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of only uppercase and lowercase English letters (no punctuation).
- For example, "Hello World", "HELLO", and "hello world hello world" are all sentences.
You are given a sentence s and an ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"I love to code\",k = 3) == \"I love to\"\n assert candidate(s = \"Python is great\",k = 2) == \"Python is\"\n assert candidate(s = \"Python programming is fun\",k = 2) == \"Python programming\"\n assert candidate(s = \"A q... | [
"\"Hello how are you Contestant\"\n4",
"\"What is the solution to this problem\"\n4",
"\"chopper is not a tanuki\"\n5"
] | [
"It's easier to solve this problem on an array of strings so parse the string to an array of words",
"After return the first k words as a sentence"
] | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().truncateSentence",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:36",
"tests_total": 94,
... | typescript | {
"raw_signature": "function truncateSentence(s: string, k: number): string {",
"container": null,
"callable": "truncateSentence",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "string",
"signature_source": "l... |
1,817 | finding-the-users-active-minutes | Medium | You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented by a 2D integer array logs where each logs[i] = [ID_i, time_i] indicates that the user with ID_i performed an action at the minute time_i.
Multiple users can perform actions simultaneously, and a single user can perform m... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],k = 3) == [0, 0, 3]\n assert candidate(logs = [[10, 1], [11, 2], [10, 2], [11, 3], [10, 3], [11, 4]],k = 4) == [0, 0, 2, 0]\n assert candidate(logs = [... | [
"[[0,5],[1,2],[0,2],[0,5],[1,3]]\n5",
"[[1,1],[2,2],[2,3]]\n4"
] | [
"Try to find the number of different minutes when action happened for each user.",
"For each user increase the value of the answer array index which matches the UAM for this user."
] | {
"canonical_parameter_names": [
"logs",
"k"
],
"leetcode_dataset_entry_point": "Solution().findingUsersActiveMinutes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:39",
"tests_to... | typescript | {
"raw_signature": "function findingUsersActiveMinutes(logs: number[][], k: number): number[] {",
"container": null,
"callable": "findingUsersActiveMinutes",
"parameters": [
{
"name": "logs",
"type": "number[][]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": ... |
1,818 | minimum-absolute-sum-difference | Medium | You are given two positive integer arrays nums1 and nums2, both of length n.
The absolute sum difference of arrays nums1 and nums2 is defined as the sum of |nums1[i] - nums2[i]| for each 0 <= i < n (0-indexed).
You can replace at most one element of nums1 with any other element in nums1 to minimize the absolute sum d... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [1, 1, 1]) == 299997\n assert candidate(nums1 = [1, 7, 5],nums2 = [2, 3, 5]) == 3\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1]) == 16\n assert candidate(nums1 = [100000, 1... | [
"[1,7,5]\n[2,3,5]",
"[2,4,6,8,10]\n[2,4,6,8,10]",
"[1,10,4,4,2,7]\n[9,3,5,1,7,4]"
] | [
"Go through each element and test the optimal replacements.",
"There are only 2 possible replacements for each element (higher and lower) that are optimal."
] | {
"canonical_parameter_names": [
"nums1",
"nums2"
],
"leetcode_dataset_entry_point": "Solution().minAbsoluteSumDiff",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:41",
"tests_tota... | typescript | {
"raw_signature": "function minAbsoluteSumDiff(nums1: number[], nums2: number[]): number {",
"container": null,
"callable": "minAbsoluteSumDiff",
"parameters": [
{
"name": "nums1",
"type": "number[]"
},
{
"name": "nums2",
"type": "number[]"
}
],
"return_type": "numbe... |
1,819 | number-of-different-subsequences-gcds | Hard | You are given an array nums that consists of positive integers.
The GCD of a sequence of numbers is defined as the greatest integer that divides all the numbers in the sequence evenly.
- For example, the GCD of the sequence [4,6,16] is 2.
A subsequence of an array is a sequence that can be formed by removing some el... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [6, 10, 3]) == 5\n assert candidate(nums = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [5, 15, 40, 5, 6]) == 7\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 102... | [
"[6,10,3]",
"[5,15,40,5,6]"
] | [
"Think of how to check if a number x is a gcd of a subsequence.",
"If there is such subsequence, then all of it will be divisible by x. Moreover, if you divide each number in the subsequence by x , then the gcd of the resulting numbers will be 1.",
"Adding a number to a subsequence cannot increase its gcd. So, ... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countDifferentSubsequenceGCDs",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:44",
"tests_total":... | typescript | {
"raw_signature": "function countDifferentSubsequenceGCDs(nums: number[]): number {",
"container": null,
"callable": "countDifferentSubsequenceGCDs",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type... |
1,822 | sign-of-the-product-of-an-array | Easy | Implement a function signFunc(x) that returns:
- 1 if x is positive.
- -1 if x is negative.
- 0 if x is equal to 0.
You are given an integer array nums. Let product be the product of all values in the array nums.
Return signFunc(product).
Example 1:
Input: nums = [-1,-2,-3,-4,3,2,1]
Output: 1
Explanation: The prod... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [-1]) == -1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [0, 0, 0]) == 0\n assert candidate(nums = [-99, -98, -97, -96, -95, -94, -93, -92, -91, -90]) == 1\n assert candidate(nums = [100, -100, 100]) =... | [
"[-1,-2,-3,-4,3,2,1]",
"[1,5,0,2,-3]",
"[-1,1,-1,1,-1]"
] | [
"If there is a 0 in the array the answer is 0",
"To avoid overflow make all the negative numbers -1 and all positive numbers 1 and calculate the prod"
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().arraySign",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:49",
"tests_total": 96,
"tests_droppe... | typescript | {
"raw_signature": "function arraySign(nums: number[]): number {",
"container": null,
"callable": "arraySign",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,823 | find-the-winner-of-the-circular-game | Medium | There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwise from the i^th friend brings you to the (i+1)^th friend for 1 <= i < n, and moving clockwise from the n^th friend brings you to the 1^st friend.
The rules of ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 3,k = 1) == 3\n assert candidate(n = 3,k = 3) == 2\n assert candidate(n = 5,k = 2) == 3\n assert candidate(n = 7,k = 3) == 4\n assert candidate(n = 7,k = 1) == 7\n assert candidate(n = 6,k = 5) == 1\n assert candida... | [
"5\n2",
"6\n5"
] | [
"Simulate the process.",
"Maintain in a circular list the people who are still in the circle and the current person you are standing at.",
"In each turn, count k people and remove the last person from the list."
] | {
"canonical_parameter_names": [
"n",
"k"
],
"leetcode_dataset_entry_point": "Solution().findTheWinner",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:51",
"tests_total": 83,
"te... | typescript | {
"raw_signature": "function findTheWinner(n: number, k: number): number {",
"container": null,
"callable": "findTheWinner",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcod... |
1,824 | minimum-sideway-jumps | Medium | There is a 3 lane road of length n that consists of n + 1 points labeled from 0 to n. A frog starts at point 0 in the second lane and wants to jump to point n. However, there could be obstacles along the way.
You are given an array obstacles of length n + 1 where each obstacles[i] (ranging from 0 to 3) describes an ob... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(obstacles = [0, 1, 0, 0, 2, 0, 0, 3, 0, 0]) == 1\n assert candidate(obstacles = [0, 0, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 1, 0, 3, 2, 1, 0]) == 4\n assert candidate(obstacles = [0, 0, 1, 0, 0, 2, 0, 0, 3,... | [
"[0,1,2,3,0]",
"[0,1,1,3,3,0]",
"[0,2,1,0,3,0]"
] | [
"At a given point, there are only 3 possible states for where the frog can be.",
"Check all the ways to move from one point to the next and update the minimum side jumps for each lane."
] | {
"canonical_parameter_names": [
"obstacles"
],
"leetcode_dataset_entry_point": "Solution().minSideJumps",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:54",
"tests_total": 132,
"tes... | typescript | {
"raw_signature": "function minSideJumps(obstacles: number[]): number {",
"container": null,
"callable": "minSideJumps",
"parameters": [
{
"name": "obstacles",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
1,827 | minimum-operations-to-make-the-array-increasing | Easy | You are given an integer array nums (0-indexed). In one operation, you can choose an element of the array and increment it by 1.
- For example, if nums = [1,2,3], you can choose to increment nums[1] to make nums = [1,3,3].
Return the minimum number of operations needed to make nums strictly increasing.
An array nums... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [10000, 1, 1, 1, 1]) == 40006\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 25\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [10, 9, 8, 7,... | [
"[1,1,1]",
"[1,5,2,4,1]",
"[8]"
] | [
"nums[i+1] must be at least equal to nums[i] + 1.",
"Think greedily. You don't have to increase nums[i+1] beyond nums[i]+1.",
"Iterate on i and set nums[i] = max(nums[i-1]+1, nums[i]) ."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().minOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:31:58",
"tests_total": 118,
"tests_d... | typescript | {
"raw_signature": "function minOperations(nums: number[]): number {",
"container": null,
"callable": "minOperations",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
1,828 | queries-on-number-of-points-inside-a-circle | Medium | You are given an array points where points[i] = [x_i, y_i] is the coordinates of the i^th point on a 2D plane. Multiple points can have the same coordinates.
You are also given an array queries where queries[j] = [x_j, y_j, r_j] describes a circle centered at (x_j, y_j) with a radius of r_j.
For each query queries[j]... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 2, 2], [2, 2, 2], [4, 3, 2], [4, 3, 3]]) == [2, 3, 2, 4]\n assert candidate(points = [[1, 3], [3, 3], [5, 3], [2, 2]],queries = [[2, 3, 1], [4, 3, 1], [1, 1, 2]]) == [3,... | [
"[[1,3],[3,3],[5,3],[2,2]]\n[[2,3,1],[4,3,1],[1,1,2]]",
"[[1,1],[2,2],[3,3],[4,4],[5,5]]\n[[1,2,2],[2,2,2],[4,3,2],[4,3,3]]"
] | [
"For a point to be inside a circle, the euclidean distance between it and the circle's center needs to be less than or equal to the radius.",
"Brute force for each circle and iterate overall points and find those inside it."
] | {
"canonical_parameter_names": [
"points",
"queries"
],
"leetcode_dataset_entry_point": "Solution().countPoints",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:00",
"tests_total": ... | typescript | {
"raw_signature": "function countPoints(points: number[][], queries: number[][]): number[] {",
"container": null,
"callable": "countPoints",
"parameters": [
{
"name": "points",
"type": "number[][]"
},
{
"name": "queries",
"type": "number[][]"
}
],
"return_type": "num... |
1,829 | maximum-xor-for-each-query | Medium | You are given a sorted array nums of n non-negative integers and an integer maximumBit. You want to perform the following query n times:
1. Find a non-negative integer k < 2^maximumBit such that nums[0] XOR nums[1] XOR ... XOR nums[nums.length-1] XOR k is maximized. k is the answer to the i^th query.
2. Remove the las... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [2, 3, 4, 7],maximumBit = 3) == [5, 2, 6, 5]\n assert candidate(nums = [0, 1, 1, 3],maximumBit = 2) == [0, 3, 2, 3]\n assert candidate(nums = [1, 2, 4, 8, 16],maximumBit = 5) == [0, 16, 24, 28, 30]\n assert candidate(nums... | [
"[0,1,1,3]\n2",
"[2,3,4,7]\n3",
"[0,1,2,2,5,7]\n3"
] | [
"Note that the maximum possible XOR result is always 2^(maximumBit) - 1",
"So the answer for a prefix is the XOR of that prefix XORed with 2^(maximumBit)-1"
] | {
"canonical_parameter_names": [
"nums",
"maximumBit"
],
"leetcode_dataset_entry_point": "Solution().getMaximumXor",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:03",
"tests_total... | typescript | {
"raw_signature": "function getMaximumXor(nums: number[], maximumBit: number): number[] {",
"container": null,
"callable": "getMaximumXor",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "maximumBit",
"type": "number"
}
],
"return_type": "number[]"... |
1,832 | check-if-the-sentence-is-pangram | Easy | A pangram is a sentence where every letter of the English alphabet appears at least once.
Given a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise.
Example 1:
Input: sentence = "thequickbrownfoxjumpsoverthelazydog"
Output: true
Explanation: sentence ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(sentence = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(sentence = \"quickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"aaaaabbbbbccccc\") == False\n assert candid... | [
"\"thequickbrownfoxjumpsoverthelazydog\"",
"\"leetcode\""
] | [
"Iterate over the string and mark each character as found (using a boolean array, bitmask, or any other similar way).",
"Check if the number of found characters equals the alphabet length."
] | {
"canonical_parameter_names": [
"sentence"
],
"leetcode_dataset_entry_point": "Solution().checkIfPangram",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:05",
"tests_total": 98,
"tes... | typescript | {
"raw_signature": "function checkIfPangram(sentence: string): boolean {",
"container": null,
"callable": "checkIfPangram",
"parameters": [
{
"name": "sentence",
"type": "string"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
1,833 | maximum-ice-cream-bars | Medium | It is a sweltering summer day, and a boy wants to buy some ice cream bars.
At the store, there are n ice cream bars. You are given an array costs of length n, where costs[i] is the price of the i^th ice cream bar in coins. The boy initially has coins coins to spend, and he wants to buy as many ice cream bars as possib... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(costs = [1, 3, 2, 4, 1],coins = 7) == 4\n assert candidate(costs = [10, 6, 8, 7, 7, 8],coins = 5) == 0\n assert candidate(costs = [1],coins = 1) == 1\n assert candidate(costs = [1, 6, 3, 1, 2, 5],coins = 20) == 6\n assert can... | [
"[1,3,2,4,1]\n7",
"[10,6,8,7,7,8]\n5",
"[1,6,3,1,2,5]\n20"
] | [
"It is always optimal to buy the least expensive ice cream bar first.",
"Sort the prices so that the cheapest ice cream bar comes first."
] | {
"canonical_parameter_names": [
"costs",
"coins"
],
"leetcode_dataset_entry_point": "Solution().maxIceCream",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:07",
"tests_total": 75,... | typescript | {
"raw_signature": "function maxIceCream(costs: number[], coins: number): number {",
"container": null,
"callable": "maxIceCream",
"parameters": [
{
"name": "costs",
"type": "number[]"
},
{
"name": "coins",
"type": "number"
}
],
"return_type": "number",
"signature_s... |
1,834 | single-threaded-cpu | Medium | You are given n tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTime_i, processingTime_i] means that the i^th task will be available to process at enqueueTime_i and will take processingTime_ito finish processing.
You have a single-threaded CPU that can process at most on... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(tasks = [[1, 3], [2, 2], [3, 1], [4, 4]]) == [0, 2, 1, 3]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 3], [2, 5], [8, 2], [7, 4], [10, 2]]) == [0, 1, 2, 4,... | [
"[[1,2],[2,4],[3,2],[4,1]]",
"[[7,10],[7,12],[7,5],[7,4],[7,2]]"
] | [
"To simulate the problem we first need to note that if at any point in time there are no enqueued tasks we need to wait to the smallest enqueue time of a non-processed element",
"We need a data structure like a min-heap to support choosing the task with the smallest processing time from all the enqueued tasks"
] | {
"canonical_parameter_names": [
"tasks"
],
"leetcode_dataset_entry_point": "Solution().getOrder",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:10",
"tests_total": 109,
"tests_dropp... | typescript | {
"raw_signature": "function getOrder(tasks: number[][]): number[] {",
"container": null,
"callable": "getOrder",
"parameters": [
{
"name": "tasks",
"type": "number[][]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
1,835 | find-xor-sum-of-all-pairs-bitwise-and | Hard | The XOR sum of a list is the bitwise XOR of all its elements. If the list only contains one element, then its XOR sum will be equal to this element.
- For example, the XOR sum of [1,2,3,4] is equal to 1 XOR 2 XOR 3 XOR 4 = 4, and the XOR sum of [3] is equal to 3.
You are given two 0-indexed arrays arr1 and arr2 that ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr1 = [1, 2, 3],arr2 = [6, 5]) == 0\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1]) == 1\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10]) == 0\n assert candidate(arr1 = [1000000000],arr2 = [1... | [
"[1,2,3]\n[6,5]",
"[12]\n[4]"
] | [
"Think about (a&b) ^ (a&c). Can you simplify this expression?",
"It is equal to a&(b^c). Then, (arr1[i]&arr2[0])^(arr1[i]&arr2[1]).. = arr1[i]&(arr2[0]^arr2[1]^arr[2]...).",
"Let arr2XorSum = (arr2[0]^arr2[1]^arr2[2]...), arr1XorSum = (arr1[0]^arr1[1]^arr1[2]...) so the final answer is (arr2XorSum&arr1[0]) ^ (a... | {
"canonical_parameter_names": [
"arr1",
"arr2"
],
"leetcode_dataset_entry_point": "Solution().getXORSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:12",
"tests_total": 103,
... | typescript | {
"raw_signature": "function getXORSum(arr1: number[], arr2: number[]): number {",
"container": null,
"callable": "getXORSum",
"parameters": [
{
"name": "arr1",
"type": "number[]"
},
{
"name": "arr2",
"type": "number[]"
}
],
"return_type": "number",
"signature_sourc... |
1,837 | sum-of-digits-in-base-k | Easy | Given an integer n (in base 10) and a base k, return the sum of the digits of n after converting n from base 10 to base k.
After converting, each digit should be interpreted as a base 10 number, and the sum should be returned in base 10.
Example 1:
Input: n = 34, k = 6
Output: 9
Explanation: 34 (base 10) expressed i... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 64,k = 2) == 1\n assert candidate(n = 7,k = 3) == 3\n assert candidate(n = 42,k = 5) == 6\n assert candidate(n = 50,k = 4) == 5\n assert candidate(n = 100,k = 3) == 4\n assert candidate(n = 10,k = 10) == 1\n assert ... | [
"34\n6",
"10\n10"
] | [
"Convert the given number into base k."
] | {
"canonical_parameter_names": [
"n",
"k"
],
"leetcode_dataset_entry_point": "Solution().sumBase",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:17",
"tests_total": 87,
"tests_dr... | typescript | {
"raw_signature": "function sumBase(n: number, k: number): number {",
"container": null,
"callable": "sumBase",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippe... |
1,838 | frequency-of-the-most-frequent-element | Medium | The frequency of an element is the number of times it occurs in an array.
You are given an integer array nums and an integer k. In one operation, you can choose an index of nums and increment the element at that index by 1.
Return the maximum possible frequency of an element after performing at most k operations.
Ex... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 4],k = 5) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 25) == 7\n assert candidate(nums = [5, 5, 5, 5, 5],k = 10) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4],k = 7) == 6\n assert c... | [
"[1,2,4]\n5",
"[1,4,8,13]\n5",
"[3,9,6]\n2"
] | [
"Note that you can try all values in a brute force manner and find the maximum frequency of that value.",
"To find the maximum frequency of a value consider the biggest elements smaller than or equal to this value"
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxFrequency",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:19",
"tests_total": 99,
"... | typescript | {
"raw_signature": "function maxFrequency(nums: number[], k: number): number {",
"container": null,
"callable": "maxFrequency",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": ... |
1,839 | longest-substring-of-all-vowels-in-order | Medium | A string is considered beautiful if it satisfies the following conditions:
- Each of the 5 English vowels ('a', 'e', 'i', 'o', 'u') must appear at least once in it.
- The letters must be sorted in alphabetical order (i.e. all 'a's before 'e's, all 'e's before 'i's, etc.).
For example, strings "aeiou" and "aaaaaaeiiii... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuooaauuaeiuuuuuuuuuuuuuuuuuuuuaaa\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuaauuaeiu\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuuuuuuuuuuuuuuuuuuaaaaaaeiou\")... | [
"\"aeiaaioaaaaeiiiiouuuooaauuaeiu\"",
"\"aeeeiiiioooauuuaeiou\"",
"\"a\""
] | [
"Start from each 'a' and find the longest beautiful substring starting at that index.",
"Based on the current character decide if you should include the next character in the beautiful substring."
] | {
"canonical_parameter_names": [
"word"
],
"leetcode_dataset_entry_point": "Solution().longestBeautifulSubstring",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:22",
"tests_total": 20,... | typescript | {
"raw_signature": "function longestBeautifulSubstring(word: string): number {",
"container": null,
"callable": "longestBeautifulSubstring",
"parameters": [
{
"name": "word",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "l... |
1,840 | maximum-building-height | Hard | You want to build n new buildings in a city. The new buildings will be built in a line and are labeled from 1 to n.
However, there are city restrictions on the heights of the new buildings:
- The height of each building must be a non-negative integer.
- The height of the first building must be 0.
- The height differe... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 6,restrictions = []) == 5\n assert candidate(n = 5,restrictions = [[2, 1], [4, 1]]) == 2\n assert candidate(n = 100,restrictions = [[10, 5], [50, 25], [90, 10]]) == 37\n assert candidate(n = 1000000,restrictions = [[500000, ... | [
"5\n[[2,1],[4,1]]",
"6\n[]",
"10\n[[5,3],[2,5],[7,4],[10,3]]"
] | [
"Is it possible to find the max height if given the height range of a particular building?",
"You can find the height range of a restricted building by doing 2 passes from the left and right."
] | {
"canonical_parameter_names": [
"n",
"restrictions"
],
"leetcode_dataset_entry_point": "Solution().maxBuilding",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:24",
"tests_total": ... | typescript | {
"raw_signature": "function maxBuilding(n: number, restrictions: number[][]): number {",
"container": null,
"callable": "maxBuilding",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "restrictions",
"type": "number[][]"
}
],
"return_type": "number",
"s... |
1,844 | replace-all-digits-with-characters | Easy | You are given a 0-indexed string s that has lowercase English letters in its even indices and digits in its odd indices.
You must perform an operation shift(c, x), where c is a character and x is a digit, that returns the x^th character after c.
- For example, shift('a', 5) = 'f' and shift('x', 0) = 'x'.
For every o... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"x1y2z3a4b5c6d7e8f9g0\") == \"xyy{z}aebgcidkemfogg\"\n assert candidate(s = \"x5y5z5\") == \"x}y~z\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0\") == \"ajbjcjdjejfjgjhjijjj\"\n assert candidate(s = \"a9b9c9d9\") == \"aj... | [
"\"a1c1e1\"",
"\"a1b2c3d4e\""
] | [
"We just need to replace every even positioned character with the character s[i] positions ahead of the character preceding it",
"Get the position of the preceeding character in alphabet then advance it s[i] positions and get the character at that position"
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().replaceDigits",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:29",
"tests_total": 115,
"tests_drop... | typescript | {
"raw_signature": "function replaceDigits(s: string): string {",
"container": null,
"callable": "replaceDigits",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,846 | maximum-element-after-decreasing-and-rearranging | Medium | You are given an array of positive integers arr. Perform some operations (possibly none) on arr so that it satisfies these conditions:
- The value of the first element in arr must be 1.
- The absolute difference between any 2 adjacent elements must be less than or equal to 1. In other words, abs(arr[i] - arr[i - 1]) <... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [3, 2, 1]) == 3\n assert candidate(arr = [5, 4, 3, 2, 1]) == 5\n assert candidate(arr = [1, 1000000000, 2, 3, 4]) == 5\n assert candidate(arr = [9, 7, 5, 3, 1]) == 5\n assert candidate(arr = [5, 5, 5, 5, 5]) == 5\n a... | [
"[2,2,1,2,1]",
"[100,1,1000]",
"[1,2,3,4,5]"
] | [
"Sort the Array.",
"Decrement each element to the largest integer that satisfies the conditions."
] | {
"canonical_parameter_names": [
"arr"
],
"leetcode_dataset_entry_point": "Solution().maximumElementAfterDecrementingAndRearranging",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:31",
... | typescript | {
"raw_signature": "function maximumElementAfterDecrementingAndRearranging(arr: number[]): number {",
"container": null,
"callable": "maximumElementAfterDecrementingAndRearranging",
"parameters": [
{
"name": "arr",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "l... |
1,847 | closest-room | Hard | There is a hotel with n rooms. The rooms are represented by a 2D integer array rooms where rooms[i] = [roomId_i, size_i] denotes that there is a room with room number roomId_i and size equal to size_i. Each roomId_i is guaranteed to be unique.
You are also given k queries in a 2D array queries where queries[j] = [pref... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8]],queries = [[15, 4], [25, 7], [35, 2]]) == [10, 30, 30]\n assert candidate(rooms = [[5, 5], [10, 5], [15, 5], [20, 5]],queries = [[7, 5], [12, 5], [17, 5], [22, 5]]) == [5, 10, 15, 20]\n assert ca... | [
"[[2,2],[1,2],[3,2]]\n[[3,1],[3,3],[5,2]]",
"[[1,4],[2,3],[3,5],[4,1],[5,2]]\n[[2,3],[2,4],[2,5]]"
] | [
"Is there a way to sort the queries so it's easier to search the closest room larger than the size?",
"Use binary search to speed up the search time."
] | {
"canonical_parameter_names": [
"rooms",
"queries"
],
"leetcode_dataset_entry_point": "Solution().closestRoom",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:34",
"tests_total": 2... | typescript | {
"raw_signature": "function closestRoom(rooms: number[][], queries: number[][]): number[] {",
"container": null,
"callable": "closestRoom",
"parameters": [
{
"name": "rooms",
"type": "number[][]"
},
{
"name": "queries",
"type": "number[][]"
}
],
"return_type": "numbe... |
1,848 | minimum-distance-to-the-target-element | Easy | Given an integer array nums (0-indexed) and two integers target and start, find an index i such that nums[i] == target and abs(i - start) is minimized. Note that abs(x) is the absolute value of x.
Return abs(i - start).
It is guaranteed that target exists in nums.
Example 1:
Input: nums = [1,2,3,4,5], target = 5, s... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 1, 4, 1],target = 1,start = 2) == 1\n assert candidate(nums = [1, 5, 3, 4, 5],target = 5,start = 2) == 1\n assert candidate(nums = [4, 1, 3, 5, 2],target = 2,start = 1) == 3\n assert candidate(nums = [4, 1, 3, 5, 6],t... | [
"[1,2,3,4,5]\n5\n3",
"[1]\n1\n0",
"[5,3,6]\n5\n2"
] | [
"Loop in both directions until you find the target element.",
"For each index i such that nums[i] == target calculate abs(i - start)."
] | {
"canonical_parameter_names": [
"nums",
"target",
"start"
],
"leetcode_dataset_entry_point": "Solution().getMinDistance",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:36",
"t... | typescript | {
"raw_signature": "function getMinDistance(nums: number[], target: number, start: number): number {",
"container": null,
"callable": "getMinDistance",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "target",
"type": "number"
},
{
"name": "sta... |
1,849 | splitting-a-string-into-descending-consecutive-values | Medium | You are given a string s that consists of only digits.
Check if we can split s into two or more non-empty substrings such that the numerical values of the substrings are in descending order and the difference between numerical values of every two adjacent substrings is equal to 1.
- For example, the string s = "00900... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"21\") == True\n assert candidate(s = \"9876543210\") == True\n assert candidate(s = \"050043\") == True\n assert candidate(s = \"989796959493929190\") == True\n assert candidate(s = \"1009998\") == True\n assert cand... | [
"\"1234\"",
"\"050043\"",
"\"9080701\""
] | [
"One solution is to try all possible splits using backtrack",
"Look out for trailing zeros in string"
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().splitString",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:38",
"tests_total": 135,
"tests_droppe... | typescript | {
"raw_signature": "function splitString(s: string): boolean {",
"container": null,
"callable": "splitString",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,850 | minimum-adjacent-swaps-to-reach-the-kth-smallest-number | Medium | You are given a string num, representing a large integer, and an integer k.
We call some integer wonderful if it is a permutation of the digits in num and is greater in value than num. There can be many wonderful integers. However, we only care about the smallest-valued ones.
- For example, when num = "5489355142":
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = \"111222333\",k = 10) == 3\n assert candidate(num = \"1234567890\",k = 5) == 2\n assert candidate(num = \"1111111111\",k = 5) == 0\n assert candidate(num = \"9876543210\",k = 3) == 0\n assert candidate(num = \"548935514... | [
"\"5489355142\"\n4",
"\"11112\"\n4",
"\"00123\"\n1"
] | [
"Find the next permutation of the given string k times.",
"Try to move each element to its correct position and calculate the number of steps."
] | {
"canonical_parameter_names": [
"num",
"k"
],
"leetcode_dataset_entry_point": "Solution().getMinSwaps",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:40",
"tests_total": 105,
"t... | typescript | {
"raw_signature": "function getMinSwaps(num: string, k: number): number {",
"container": null,
"callable": "getMinSwaps",
"parameters": [
{
"name": "num",
"type": "string"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcod... |
1,851 | minimum-interval-to-include-each-query | Hard | You are given a 2D integer array intervals, where intervals[i] = [left_i, right_i] describes the i^th interval starting at left_i and ending at right_i (inclusive). The size of an interval is defined as the number of integers it contains, or more formally right_i - left_i + 1.
You are also given an integer array queri... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(intervals = [[1, 1], [2, 2]],queries = [1, 2, 3]) == [1, 1, -1]\n assert candidate(intervals = [[1, 10], [10, 20], [15, 25]],queries = [5, 10, 15, 20, 25]) == [10, 10, 11, 11, 11]\n assert candidate(intervals = [[1, 1]],queries = [... | [
"[[1,4],[2,4],[3,6],[4,4]]\n[2,3,4,5]",
"[[2,3],[2,5],[1,8],[20,25]]\n[2,19,5,22]"
] | [
"Is there a way to order the intervals and queries such that it takes less time to query?",
"Is there a way to add and remove intervals by going from the smallest query to the largest query to find the minimum size?"
] | {
"canonical_parameter_names": [
"intervals",
"queries"
],
"leetcode_dataset_entry_point": "Solution().minInterval",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:43",
"tests_total... | typescript | {
"raw_signature": "function minInterval(intervals: number[][], queries: number[]): number[] {",
"container": null,
"callable": "minInterval",
"parameters": [
{
"name": "intervals",
"type": "number[][]"
},
{
"name": "queries",
"type": "number[]"
}
],
"return_type": "n... |
1,854 | maximum-population-year | Easy | You are given a 2D integer array logs where each logs[i] = [birth_i, death_i] indicates the birth and death years of the i^th person.
The population of some year x is the number of people alive during that year. The i^th person is counted in year x's population if x is in the inclusive range [birth_i, death_i - 1]. No... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(logs = [[2000, 2005], [2005, 2010], [2010, 2015]]) == 2000\n assert candidate(logs = [[1980, 1985], [1985, 1990], [1990, 1995], [1995, 2000]]) == 1980\n assert candidate(logs = [[2000, 2010], [1990, 2000], [2000, 2020]]) == 2000\n ... | [
"[[1993,1999],[2000,2010]]",
"[[1950,1961],[1960,1971],[1970,1981]]"
] | [
"For each year find the number of people whose birth_i ≤ year and death_i > year.",
"Find the maximum value between all years."
] | {
"canonical_parameter_names": [
"logs"
],
"leetcode_dataset_entry_point": "Solution().maximumPopulation",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:48",
"tests_total": 91,
"test... | typescript | {
"raw_signature": "function maximumPopulation(logs: number[][]): number {",
"container": null,
"callable": "maximumPopulation",
"parameters": [
{
"name": "logs",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
1,855 | maximum-distance-between-a-pair-of-values | Medium | You are given two non-increasing 0-indexed integer arrays nums1 and nums2.
A pair of indices (i, j), where 0 <= i < nums1.length and 0 <= j < nums2.length, is valid if both i <= j and nums1[i] <= nums2[j]. The distance of the pair is j - i.
Return the maximum distance of any valid pair (i, j). If there are no valid p... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums1 = [100],nums2 = [101]) == 0\n assert candidate(nums1 = [30, 29, 19, 5],nums2 = [25, 25, 25, 25, 25]) == 2\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [10, 9, 8, 7, 6]... | [
"[55,30,5,4,2]\n[100,20,10,10,5]",
"[2,2,2]\n[10,10,1]",
"[30,29,19,5]\n[25,25,25,25,25]"
] | [
"Since both arrays are sorted in a non-increasing way, this means that for each value in the first array, we can find the farthest value larger than or equal to it using binary search.",
"There is another solution using a two pointers approach. Since the first array is non-increasing, the farthest j such that num... | {
"canonical_parameter_names": [
"nums1",
"nums2"
],
"leetcode_dataset_entry_point": "Solution().maxDistance",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:50",
"tests_total": 75,... | typescript | {
"raw_signature": "function maxDistance(nums1: number[], nums2: number[]): number {",
"container": null,
"callable": "maxDistance",
"parameters": [
{
"name": "nums1",
"type": "number[]"
},
{
"name": "nums2",
"type": "number[]"
}
],
"return_type": "number",
"signatu... |
1,856 | maximum-subarray-min-product | Medium | The min-product of an array is equal to the minimum value in the array multiplied by the array's sum.
- For example, the array [3,2,5] (minimum value is 2) has a min-product of 2 * (3+2+5) = 2 * 10 = 20.
Given an array of integers nums, return the maximum min-product of any non-empty subarray of nums. Since the answe... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 9, 6, 8, 7]) == 180\n assert candidate(nums = [2, 1]) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 180\n assert candidate(nums = [... | [
"[1,2,3,2]",
"[2,3,3,1,2]",
"[3,1,5,6,4,2]"
] | [
"Is there a way we can sort the elements to simplify the problem?",
"Can we find the maximum min-product for every value in the array?"
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maxSumMinProduct",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:53",
"tests_total": 101,
"test... | typescript | {
"raw_signature": "function maxSumMinProduct(nums: number[]): number {",
"container": null,
"callable": "maxSumMinProduct",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
1,857 | largest-color-value-in-a-directed-graph | Hard | There is a directed graph of n colored nodes and m edges. The nodes are numbered from 0 to n - 1.
You are given a string colors where colors[i] is a lowercase English letter representing the color of the i^th node in this graph (0-indexed). You are also given a 2D array edges where edges[j] = [a_j, b_j] indicates that... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(colors = \"abcde\",edges = []) == 1\n assert candidate(colors = \"abcdefghijklmnopqrstuvwxyz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15],... | [
"\"abaca\"\n[[0,1],[0,2],[2,3],[3,4]]",
"\"a\"\n[[0,0]]"
] | [
"Use topological sort.",
"let dp[u][c] := the maximum count of vertices with color c of any path starting from vertex u. (by JerryJin2905)"
] | {
"canonical_parameter_names": [
"colors",
"edges"
],
"leetcode_dataset_entry_point": "Solution().largestPathValue",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:32:56",
"tests_total... | typescript | {
"raw_signature": "function largestPathValue(colors: string, edges: number[][]): number {",
"container": null,
"callable": "largestPathValue",
"parameters": [
{
"name": "colors",
"type": "string"
},
{
"name": "edges",
"type": "number[][]"
}
],
"return_type": "number"... |
1,859 | sorting-the-sentence | Easy | A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase English letters.
A sentence can be shuffled by appending the 1-indexed word position to each word then rearranging the words in the sentence.
- For example, the sentence... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"eight8 seven7 six6 five5 four4 three3 two2 one1\") == \"one two three four five six seven eight\"\n assert candidate(s = \"seven7 six6 five5 four4 three3 two2 one1\") == \"one two three four five six seven\"\n assert candidat... | [
"\"is2 sentence4 This1 a3\"",
"\"Myself2 Me1 I4 and3\""
] | [
"Divide the string into the words as an array of strings",
"Sort the words by removing the last character from each word and sorting according to it"
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().sortSentence",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:00",
"tests_total": 70,
"tests_droppe... | typescript | {
"raw_signature": "function sortSentence(s: string): string {",
"container": null,
"callable": "sortSentence",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,860 | incremental-memory-leak | Medium | You are given two integers memory1 and memory2 representing the available memory in bits on two memory sticks. There is currently a faulty program running that consumes an increasing amount of memory every second.
At the i^th second (starting from 1), i bits of memory are allocated to the stick with more available mem... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(memory1 = 0,memory2 = 0) == [1, 0, 0]\n assert candidate(memory1 = 2147483647,memory2 = 2147483647) == [92681, 88047, 41707]\n assert candidate(memory1 = 1000000000,memory2 = 1000000000) == [63245, 49116, 17494]\n assert candida... | [
"2\n2",
"8\n11"
] | [
"What is the upper bound for the number of seconds?",
"Simulate the process of allocating memory."
] | {
"canonical_parameter_names": [
"memory1",
"memory2"
],
"leetcode_dataset_entry_point": "Solution().memLeak",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:02",
"tests_total": 81,... | typescript | {
"raw_signature": "function memLeak(memory1: number, memory2: number): number[] {",
"container": null,
"callable": "memLeak",
"parameters": [
{
"name": "memory1",
"type": "number"
},
{
"name": "memory2",
"type": "number"
}
],
"return_type": "number[]",
"signature_s... |
1,861 | rotating-the-box | Medium | You are given an m x n matrix of characters boxGrid representing a side-view of a box. Each cell of the box is one of the following:
- A stone '#'
- A stationary obstacle '*'
- Empty '.'
The box is rotated 90 degrees clockwise, causing some of the stones to fall due to gravity. Each stone falls down until it lands on... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(boxGrid = [['#', '.', '*', '.'], ['#', '#', '*', '.']]) == [['#', '.'], ['#', '#'], ['*', '*'], ['.', '.']]\n assert candidate(boxGrid = [['#', '.', '#']]) == [['.'], ['#'], ['#']]\n assert candidate(boxGrid = [['#', '#', '*', '.',... | [
"[[\"#\",\".\",\"#\"]]",
"[[\"#\",\".\",\"*\",\".\"],[\"#\",\"#\",\"*\",\".\"]]",
"[[\"#\",\"#\",\"*\",\".\",\"*\",\".\"],[\"#\",\"#\",\"#\",\"*\",\".\",\".\"],[\"#\",\"#\",\"#\",\".\",\"#\",\".\"]]"
] | [
"Rotate the box using the relation rotatedBox[i][j] = box[m - 1 - j][i].",
"Start iterating from the bottom of the box and for each empty cell check if there is any stone above it with no obstacles between them."
] | {
"canonical_parameter_names": [
"boxGrid"
],
"leetcode_dataset_entry_point": "Solution().rotateTheBox",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:05",
"tests_total": 114,
"tests... | typescript | {
"raw_signature": "function rotateTheBox(boxGrid: string[][]): string[][] {",
"container": null,
"callable": "rotateTheBox",
"parameters": [
{
"name": "boxGrid",
"type": "string[][]"
}
],
"return_type": "string[][]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetc... |
1,862 | sum-of-floored-pairs | Hard | Given an integer array nums, return the sum of floor(nums[i] / nums[j]) for all pairs of indices 0 <= i, j < nums.length in the array. Since the answer may be too large, return it modulo 10^9 + 7.
The floor() function returns the integer part of the division.
Example 1:
Input: nums = [2,5,9]
Output: 10
Explanation:
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 49\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 100\n assert candidate(nums = [2, 5, 9]) == 10\n assert candidate(nums = [100000, 1, 100000]) == 200005\n assert candidate(nums ... | [
"[2,5,9]",
"[7,7,7,7,7,7,7]"
] | [
"Find the frequency (number of occurrences) of all elements in the array.",
"For each element, iterate through its multiples and multiply frequencies to find the answer."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().sumOfFlooredPairs",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:09",
"tests_total": 60,
"test... | typescript | {
"raw_signature": "function sumOfFlooredPairs(nums: number[]): number {",
"container": null,
"callable": "sumOfFlooredPairs",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
1,863 | sum-of-all-subset-xor-totals | Easy | The XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty.
- For example, the XOR total of the array [2,5,6] is 2 XOR 5 XOR 6 = 1.
Given an array nums, return the sum of all XOR totals for every subset of nums.
Note: Subsets with the same elements should be counted multi... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 1, 6]) == 28\n assert candidate(nums = [1, 1, 1, 1]) == 8\n assert candidate(nums = [1, 2, 4, 8, 16]) == 496\n assert candidate(nums = [10, 11, 12]) == 60\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14]) == 896\... | [
"[1,3]",
"[5,1,6]",
"[3,4,5,6,7,8]"
] | [
"Is there a way to iterate through all the subsets of the array?",
"Can we use recursion to efficiently iterate through all the subsets?"
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().subsetXORSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:11",
"tests_total": 99,
"tests_dro... | typescript | {
"raw_signature": "function subsetXORSum(nums: number[]): number {",
"container": null,
"callable": "subsetXORSum",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
1,864 | minimum-number-of-swaps-to-make-the-binary-string-alternating | Medium | Given a binary string s, return the minimum number of character swaps to make it alternating, or -1 if it is impossible.
The string is called alternating if no two adjacent characters are equal. For example, the strings "010" and "1010" are alternating, while the string "0100" is not.
Any two characters may be swappe... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"1111\") == -1\n assert candidate(s = \"1100110\") == 2\n assert candidate(s = \"110011\") == -1\n assert candidate(s = \"00110011\") == 2\n assert candidate(s = \"0101010\") == 0\n assert candidate(s = \"111\") == -1... | [
"\"111000\"",
"\"010\"",
"\"1110\""
] | [
"Think about all valid strings of length n.",
"Try to count the mismatched positions with each valid string of length n."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().minSwaps",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:13",
"tests_total": 243,
"tests_dropped":... | typescript | {
"raw_signature": "function minSwaps(s: string): number {",
"container": null,
"callable": "minSwaps",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,866 | number-of-ways-to-rearrange-sticks-with-k-sticks-visible | Hard | There are n uniquely-sized sticks whose lengths are integers from 1 to n. You want to arrange the sticks such that exactly k sticks are visible from the left. A stick is visible from the left if there are no longer sticks to the left of it.
- For example, if the sticks are arranged [1,3,2,5,4], then the sticks with le... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 10,k = 1) == 362880\n assert candidate(n = 1000,k = 500) == 761367694\n assert candidate(n = 7,k = 4) == 735\n assert candidate(n = 1,k = 1) == 1\n assert candidate(n = 3,k = 2) == 3\n assert candidate(n = 100,k = 50) ... | [
"3\n2",
"5\n5",
"20\n11"
] | [
"Is there a way to build the solution from a base case?",
"How many ways are there if we fix the position of one stick?"
] | {
"canonical_parameter_names": [
"n",
"k"
],
"leetcode_dataset_entry_point": "Solution().rearrangeSticks",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:16",
"tests_total": 57,
"... | typescript | {
"raw_signature": "function rearrangeSticks(n: number, k: number): number {",
"container": null,
"callable": "rearrangeSticks",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "lee... |
1,869 | longer-contiguous-segments-of-ones-than-zeros | Easy | Given a binary string s, return true if the longest contiguous segment of 1's is strictly longer than the longest contiguous segment of 0's in s, or return false otherwise.
- For example, in s = "110100010" the longest continuous segment of 1s has length 2, and the longest continuous segment of 0s has length 3.
Note ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"1111\") == True\n assert candidate(s = \"111000\") == False\n assert candidate(s = \"101010\") == False\n assert candidate(s = \"11100111\") == True\n assert candidate(s = \"11001100\") == False\n assert candidate(s ... | [
"\"1101\"",
"\"111000\"",
"\"110100010\""
] | [
"Check every possible segment of 0s and 1s.",
"Is there a way to iterate through the string to keep track of the current character and its count?"
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().checkZeroOnes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:21",
"tests_total": 161,
"tests_drop... | typescript | {
"raw_signature": "function checkZeroOnes(s: string): boolean {",
"container": null,
"callable": "checkZeroOnes",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,870 | minimum-speed-to-arrive-on-time | Medium | You are given a floating-point number hour, representing the amount of time you have to reach the office. To commute to the office, you must take n trains in sequential order. You are also given an integer array dist of length n, where dist[i] describes the distance (in kilometers) of the i^th train ride.
Each train c... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(dist = [5, 4, 3, 2, 1],hour = 5.5) == 4\n assert candidate(dist = [5, 4, 1, 2],hour = 3.5) == 5\n assert candidate(dist = [1, 2, 3, 4, 5],hour = 9.0) == 2\n assert candidate(dist = [1, 3, 2],hour = 1.9) == -1\n assert candida... | [
"[1,3,2]\n6",
"[1,3,2]\n2.7",
"[1,3,2]\n1.9"
] | [
"Given the speed the trains are traveling at, can you find the total time it takes for you to arrive?",
"Is there a cutoff where any speeds larger will always allow you to arrive on time?"
] | {
"canonical_parameter_names": [
"dist",
"hour"
],
"leetcode_dataset_entry_point": "Solution().minSpeedOnTime",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:23",
"tests_total": 98... | typescript | {
"raw_signature": "function minSpeedOnTime(dist: number[], hour: number): number {",
"container": null,
"callable": "minSpeedOnTime",
"parameters": [
{
"name": "dist",
"type": "number[]"
},
{
"name": "hour",
"type": "number"
}
],
"return_type": "number",
"signature... |
1,871 | jump-game-vii | Medium | You are given a 0-indexed binary string s and two integers minJump and maxJump. In the beginning, you are standing at index 0, which is equal to '0'. You can move from index i to index j if the following conditions are fulfilled:
- i + minJump <= j <= min(i + maxJump, s.length - 1), and
- s[j] == '0'.
Return true if ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"0100100010001000\",minJump = 2,maxJump = 5) == True\n assert candidate(s = \"00001000\",minJump = 2,maxJump = 4) == True\n assert candidate(s = \"0010010010010010010010010010010010010010\",minJump = 2,maxJump = 4) == True\n ... | [
"\"011010\"\n2\n3",
"\"01101110\"\n2\n3"
] | [
"Consider for each reachable index i the interval [i + a, i + b].",
"Use partial sums to mark the intervals as reachable."
] | {
"canonical_parameter_names": [
"s",
"minJump",
"maxJump"
],
"leetcode_dataset_entry_point": "Solution().canReach",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:25",
"tests_t... | typescript | {
"raw_signature": "function canReach(s: string, minJump: number, maxJump: number): boolean {",
"container": null,
"callable": "canReach",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "minJump",
"type": "number"
},
{
"name": "maxJump",
"typ... |
1,872 | stone-game-viii | Hard | Alice and Bob take turns playing a game, with Alice starting first.
There are n stones arranged in a row. On each player's turn, while the number of stones is more than one, they will do the following:
1. Choose an integer x > 1, and remove the leftmost x stones from the row.
2. Add the sum of the removed stones' val... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(stones = [10, -10, 20, -20, 30, -30]) == 30\n assert candidate(stones = [100, 200, -300, 400, -500, 600, -700, 800]) == 600\n assert candidate(stones = [5, 5,... | [
"[-1,2,-3,4,-5]",
"[7,-6,5,10,5,-2,-6]",
"[-10,-12]"
] | [
"Let's note that the only thing that matters is how many stones were removed so we can maintain dp[numberOfRemovedStones]",
"dp[x] = max(sum of all elements up to y - dp[y]) for all y > x"
] | {
"canonical_parameter_names": [
"stones"
],
"leetcode_dataset_entry_point": "Solution().stoneGameVIII",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:28",
"tests_total": 79,
"tests_... | typescript | {
"raw_signature": "function stoneGameVIII(stones: number[]): number {",
"container": null,
"callable": "stoneGameVIII",
"parameters": [
{
"name": "stones",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
1,876 | substrings-of-size-three-with-distinct-characters | Easy | A string is good if there are no repeated characters.
Given a string s, return the number of good substrings of length three in s.
Note that if there are multiple occurrences of the same substring, every occurrence should be counted.
A substring is a contiguous sequence of characters in a string.
Example 1:
Input:... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"xyzxyzxyz\") == 7\n assert candidate(s = \"abcabcabc\") == 7\n assert candidate(s = \"xyzzaz\") == 1\n assert candidate(s = \"aabbcc\") == 0\n assert candidate(s = \"abacab\") == 2\n assert candidate(s = \"qqqppprrr\... | [
"\"xyzzaz\"",
"\"aababcabc\""
] | [
"Try using a set to find out the number of distinct characters in a substring."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().countGoodSubstrings",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:33",
"tests_total": 96,
"tests... | typescript | {
"raw_signature": "function countGoodSubstrings(s: string): number {",
"container": null,
"callable": "countGoodSubstrings",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
1,877 | minimize-maximum-pair-sum-in-array | Medium | The pair sum of a pair (a,b) is equal to a + b. The maximum pair sum is the largest pair sum in a list of pairs.
- For example, if we have pairs (1,5), (2,3), and (4,4), the maximum pair sum would be max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8.
Given an array nums of even length n, pair up the elements of nums into n / 2 p... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 6, 2, 5, 3, 4]) == 7\n assert candidate(nums = [10, 10, 10, 10]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1... | [
"[3,5,2,3]",
"[3,5,4,2,4,6]"
] | [
"Would sorting help find the optimal order?",
"Given a specific element, how would you minimize its specific pairwise sum?"
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().minPairSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:35",
"tests_total": 97,
"tests_dropp... | typescript | {
"raw_signature": "function minPairSum(nums: number[]): number {",
"container": null,
"callable": "minPairSum",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,878 | get-biggest-three-rhombus-sums-in-a-grid | Medium | You are given an m x n integer matrix grid.
A rhombus sum is the sum of the elements that form the border of a regular rhombus shape in grid. The rhombus must have the shape of a square rotated 45 degrees with each of the corners centered in a grid cell. Below is an image of four valid rhombus shapes with the correspo... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[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]]) == [104, 76, 72]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) ... | [
"[[3,4,5,1,3],[3,3,4,2,3],[20,30,200,40,10],[1,5,5,4,1],[4,3,2,2,5]]",
"[[1,2,3],[4,5,6],[7,8,9]]",
"[[7,7,7]]"
] | [
"You need to maintain only the biggest 3 distinct sums",
"The limits are small enough for you to iterate over all rhombus sizes then iterate over all possible borders to get the sums"
] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().getBiggestThree",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:38",
"tests_total": 118,
"tests... | typescript | {
"raw_signature": "function getBiggestThree(grid: number[][]): number[] {",
"container": null,
"callable": "getBiggestThree",
"parameters": [
{
"name": "grid",
"type": "number[][]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
1,879 | minimum-xor-sum-of-two-arrays | Hard | You are given two integer arrays nums1 and nums2 of length n.
The XOR sum of the two integer arrays is (nums1[0] XOR nums2[0]) + (nums1[1] XOR nums2[1]) + ... + (nums1[n - 1] XOR nums2[n - 1]) (0-indexed).
- For example, the XOR sum of [1,2,3] and [3,2,1] is equal to (1 XOR 3) + (2 XOR 2) + (3 XOR 1) = 2 + 0 + 2 = 4.... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums1 = [3, 4, 2],nums2 = [4, 2, 2]) == 1\n assert candidate(nums1 = [1, 2],nums2 = [2, 3]) == 2\n assert candidate(nums1 = [2, 3, 4, 5],nums2 = [5, 4, 3, 2]) == 0\n assert candidate(nums1 = [4, 6, 2],nums2 = [9, 3, 5]) == 17\n ... | [
"[1,2]\n[2,3]",
"[1,0,3]\n[5,3,4]"
] | [
"Since n <= 14, we can consider every subset of nums2.",
"We can represent every subset of nums2 using bitmasks."
] | {
"canonical_parameter_names": [
"nums1",
"nums2"
],
"leetcode_dataset_entry_point": "Solution().minimumXORSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:40",
"tests_total": 9... | typescript | {
"raw_signature": "function minimumXORSum(nums1: number[], nums2: number[]): number {",
"container": null,
"callable": "minimumXORSum",
"parameters": [
{
"name": "nums1",
"type": "number[]"
},
{
"name": "nums2",
"type": "number[]"
}
],
"return_type": "number",
"sig... |
1,880 | check-if-word-equals-summation-of-two-words | Easy | The letter value of a letter is its position in the alphabet starting from 0 (i.e. 'a' -> 0, 'b' -> 1, 'c' -> 2, etc.).
The numerical value of some string of lowercase English letters s is the concatenation of the letter values of each letter in s, which is then converted into an integer.
- For example, if s = "acb",... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(firstWord = \"ij\",secondWord = \"ji\",targetWord = \"ii\") == False\n assert candidate(firstWord = \"fgh\",secondWord = \"ghf\",targetWord = \"ggg\") == False\n assert candidate(firstWord = \"ij\",secondWord = \"ji\",targetWord = ... | [
"\"acb\"\n\"cba\"\n\"cdb\"",
"\"aaa\"\n\"a\"\n\"aab\"",
"\"aaa\"\n\"a\"\n\"aaaa\""
] | [
"Convert each character of each word to its numerical value.",
"Check if the numerical values satisfies the condition."
] | {
"canonical_parameter_names": [
"firstWord",
"secondWord",
"targetWord"
],
"leetcode_dataset_entry_point": "Solution().isSumEqual",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33... | typescript | {
"raw_signature": "function isSumEqual(firstWord: string, secondWord: string, targetWord: string): boolean {",
"container": null,
"callable": "isSumEqual",
"parameters": [
{
"name": "firstWord",
"type": "string"
},
{
"name": "secondWord",
"type": "string"
},
{
... |
1,881 | maximum-value-after-insertion | Medium | You are given a very large integer n, represented as a string, and an integer digit x. The digits in n and the digit x are in the inclusive range [1, 9], and n may represent a negative number.
You want to maximize n's numerical value by inserting x anywhere in the decimal representation of n. You cannot insert x to th... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = \"5486\",x = 7) == \"75486\"\n assert candidate(n = \"-11111\",x = 1) == \"-111111\"\n assert candidate(n = \"-123456789\",x = 5) == \"-1234556789\"\n assert candidate(n = \"987654321\",x = 5) == \"9876554321\"\n assert c... | [
"\"99\"\n9",
"\"-13\"\n2"
] | [
"Note that if the number is negative it's the same as positive but you look for the minimum instead.",
"In the case of maximum, if s[i] < x it's optimal that x is put before s[i].",
"In the case of minimum, if s[i] > x it's optimal that x is put before s[i]."
] | {
"canonical_parameter_names": [
"n",
"x"
],
"leetcode_dataset_entry_point": "Solution().maxValue",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:44",
"tests_total": 133,
"tests_... | typescript | {
"raw_signature": "function maxValue(n: string, x: number): string {",
"container": null,
"callable": "maxValue",
"parameters": [
{
"name": "n",
"type": "string"
},
{
"name": "x",
"type": "number"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnip... |
1,882 | process-tasks-using-servers | Medium | You are given two 0-indexed integer arrays servers and tasks of lengths n and m respectively. servers[i] is the weight of the i^th server, and tasks[j] is the time needed to process the j^th task in seconds.
Tasks are assigned to the servers using a task queue. Initially, all servers are free, and the queue is empty.
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(servers = [3, 3, 2],tasks = [1, 2, 3, 2, 1, 2]) == [2, 2, 0, 2, 1, 2]\n assert candidate(servers = [1, 1, 1],tasks = [10, 20, 30, 40, 50]) == [0, 1, 2, 0, 1]\n assert candidate(servers = [5, 1, 4, 3, 2],tasks = [2, 1, 2, 4, 5, 2, 1... | [
"[3,3,2]\n[1,2,3,2,1,2]",
"[5,1,4,3,2]\n[2,1,2,4,5,2,1]"
] | [
"You can maintain a Heap of available Servers and a Heap of unavailable servers",
"Note that the tasks will be processed in the input order so you just need to find the x-th server that will be available according to the rules"
] | {
"canonical_parameter_names": [
"servers",
"tasks"
],
"leetcode_dataset_entry_point": "Solution().assignTasks",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:47",
"tests_total": 1... | typescript | {
"raw_signature": "function assignTasks(servers: number[], tasks: number[]): number[] {",
"container": null,
"callable": "assignTasks",
"parameters": [
{
"name": "servers",
"type": "number[]"
},
{
"name": "tasks",
"type": "number[]"
}
],
"return_type": "number[]",
... |
1,883 | minimum-skips-to-arrive-at-meeting-on-time | Hard | You are given an integer hoursBefore, the number of hours you have to travel to your meeting. To arrive at your meeting, you have to travel through n roads. The road lengths are given as an integer array dist of length n, where dist[i] describes the length of the i^th road in kilometers. In addition, you are given an i... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(dist = [10, 10, 10],speed = 5,hoursBefore = 6) == 0\n assert candidate(dist = [1, 1, 1, 1, 1],speed = 1,hoursBefore = 3) == -1\n assert candidate(dist = [5, 5, 5, 5, 5],speed = 10,hoursBefore = 2) == -1\n assert candidate(dist =... | [
"[1,3,2]\n4\n2",
"[7,3,5,5]\n2\n10",
"[7,3,5,5]\n1\n10"
] | [
"Is there something you can keep track of from one road to another?",
"How would knowing the start time for each state help us solve the problem?"
] | {
"canonical_parameter_names": [
"dist",
"speed",
"hoursBefore"
],
"leetcode_dataset_entry_point": "Solution().minSkips",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:49",
"te... | typescript | {
"raw_signature": "function minSkips(dist: number[], speed: number, hoursBefore: number): number {",
"container": null,
"callable": "minSkips",
"parameters": [
{
"name": "dist",
"type": "number[]"
},
{
"name": "speed",
"type": "number"
},
{
"name": "hoursBefore... |
1,884 | egg-drop-with-2-eggs-and-n-floors | Medium | You are given two identical eggs and you have access to a building with n floors labeled from 1 to n.
You know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor higher than f will break, and any egg dropped at or below floor f will not break.
In each move, you may take an unbroken egg... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 8) == 4\n assert candidate(n = 1000) == 45\n assert candidate(n = 5) == 3\n assert candidate(n = 81) == 13\n assert candidate(n = 999) == 45\n assert candidate(n = 15) == 5\n assert candidate(n = 64) == 11\n asse... | [
"2",
"100"
] | [
"Is it really optimal to always drop the egg on the middle floor for each move?",
"Can we create states based on the number of unbroken eggs and floors to build our solution?"
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().twoEggDrop",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:51",
"tests_total": 46,
"tests_dropped"... | typescript | {
"raw_signature": "function twoEggDrop(n: number): number {",
"container": null,
"callable": "twoEggDrop",
"parameters": [
{
"name": "n",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,886 | determine-whether-matrix-can-be-obtained-by-rotation | Easy | Given two n x n binary matrices mat and target, return true if it is possible to make mat equal to target by rotating mat in 90-degree increments, or false otherwise.
Example 1:
Input: mat = [[0,1],[1,0]], target = [[1,0],[0,1]]
Output: true
Explanation: We can rotate mat 90 degrees clockwise to make mat equal target... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(mat = [[1, 0, 0], [0, 1, 0], [0, 0, 1]],target = [[0, 0, 1], [0, 1, 0], [1, 0, 0]]) == True\n assert candidate(mat = [[0, 1], [1, 0]],target = [[1, 0], [0, 1]]) == True\n assert candidate(mat = [[1, 1], [0, 0]],target = [[0, 1], [0... | [
"[[0,1],[1,0]]\n[[1,0],[0,1]]",
"[[0,1],[1,1]]\n[[1,0],[0,1]]",
"[[0,0,0],[0,1,0],[1,1,1]]\n[[1,1,1],[0,1,0],[0,0,0]]"
] | [
"What is the maximum number of rotations you have to check?",
"Is there a formula you can use to rotate a matrix 90 degrees?"
] | {
"canonical_parameter_names": [
"mat",
"target"
],
"leetcode_dataset_entry_point": "Solution().findRotation",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:56",
"tests_total": 79,... | typescript | {
"raw_signature": "function findRotation(mat: number[][], target: number[][]): boolean {",
"container": null,
"callable": "findRotation",
"parameters": [
{
"name": "mat",
"type": "number[][]"
},
{
"name": "target",
"type": "number[][]"
}
],
"return_type": "boolean",
... |
1,887 | reduction-operations-to-make-the-array-elements-equal | Medium | Given an integer array nums, your goal is to make all elements in nums equal. To complete one operation, follow these steps:
1. Find the largest value in nums. Let its index be i (0-indexed) and its value be largest. If there are multiple elements with the largest value, pick the smallest i.
2. Find the next largest v... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 20\n assert candidate(nums = [4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 5, 2, 4, 3]) == 10\n assert candidate(nums = [1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3]) =... | [
"[5,1,3]",
"[1,1,1]",
"[1,1,2,2,3]"
] | [
"Sort the array.",
"Try to reduce all elements with maximum value to the next maximum value in one operation."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().reductionOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:33:58",
"tests_total": 99,
"te... | typescript | {
"raw_signature": "function reductionOperations(nums: number[]): number {",
"container": null,
"callable": "reductionOperations",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
1,888 | minimum-number-of-flips-to-make-the-binary-string-alternating | Medium | You are given a binary string s. You are allowed to perform two types of operations on the string in any sequence:
- Type-1: Remove the character at the start of the string s and append it to the end of the string.
- Type-2: Pick any character in s and flip its value, i.e., if its value is '0' it becomes '1' and vice-... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"100100100\") == 3\n assert candidate(s = \"1111\") == 2\n assert candidate(s = \"110011\") == 3\n assert candidate(s = \"111000111000\") == 4\n assert candidate(s = \"11110000\") == 4\n assert candidate(s = \"1110\")... | [
"\"111000\"",
"\"010\"",
"\"1110\""
] | [
"Note what actually matters is how many 0s and 1s are in odd and even positions",
"For every cyclic shift we need to count how many 0s and 1s are at each parity and convert the minimum between them for each parity"
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().minFlips",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:34:00",
"tests_total": 153,
"tests_dropped":... | typescript | {
"raw_signature": "function minFlips(s: string): number {",
"container": null,
"callable": "minFlips",
"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.