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 |
|---|---|---|---|---|---|---|---|---|---|
962 | maximum-width-ramp | Medium | A ramp in an integer array nums is a pair (i, j) for which i < j and nums[i] <= nums[j]. The width of such a ramp is j - i.
Given an integer array nums, return the maximum width of a ramp in nums. If there is no ramp in nums, return 0.
Example 1:
Input: nums = [6,0,8,2,1,5]
Output: 4
Explanation: The maximum width r... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 2, 3, 3, 7, 5, 2, 4]) == 9\n assert candidate(nums = [1, 5, 2, 5, 6, 3, 5, 4]) == 7\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 9\n assert candidate(nums = [1, 5, 5, 5, 5, 5]) == 5\n assert c... | [
"[6,0,8,2,1,5]",
"[9,8,1,0,1,9,4,0,4,1]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maxWidthRamp",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:05:56",
"tests_total": 69,
"tests_dro... | typescript | {
"raw_signature": "function maxWidthRamp(nums: number[]): number {",
"container": null,
"callable": "maxWidthRamp",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
963 | minimum-area-rectangle-ii | Medium | You are given an array of points in the X-Y plane points where points[i] = [x_i, y_i].
Return the minimum area of any rectangle formed from these points, with sides not necessarily parallel to the X and Y axes. If there is not any such rectangle, return 0.
Answers within 10^-5 of the actual answer will be accepted.
... | {
"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],[1,0],[0,1]]",
"[[0,1],[2,1],[1,1],[1,0],[2,0]]",
"[[0,3],[1,2],[3,1],[1,3],[2,1]]"
] | [] | {
"canonical_parameter_names": [
"points"
],
"leetcode_dataset_entry_point": "Solution().minAreaFreeRect",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:05:58",
"tests_total": 100,
"tes... | typescript | {
"raw_signature": "function minAreaFreeRect(points: number[][]): number {",
"container": null,
"callable": "minAreaFreeRect",
"parameters": [
{
"name": "points",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
964 | least-operators-to-express-number | Hard | Given a single positive integer x, we will write an expression of the form x (op1) x (op2) x (op3) x ... where each operator op1, op2, etc. is either addition, subtraction, multiplication, or division (+, -, *, or /). For example, with x = 3, we might write 3 * 3 / 3 + 3 - 3 which is a value of 3.
When writing such an... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(x = 2,target = 123456) == 44\n assert candidate(x = 2,target = 3) == 2\n assert candidate(x = 3,target = 81) == 3\n assert candidate(x = 10,target = 1001) == 4\n assert candidate(x = 2,target = 10) == 3\n assert candidate(... | [
"3\n19",
"5\n501",
"100\n100000000"
] | [] | {
"canonical_parameter_names": [
"x",
"target"
],
"leetcode_dataset_entry_point": "Solution().leastOpsExpressTarget",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:01",
"tests_tota... | typescript | {
"raw_signature": "function leastOpsExpressTarget(x: number, target: number): number {",
"container": null,
"callable": "leastOpsExpressTarget",
"parameters": [
{
"name": "x",
"type": "number"
},
{
"name": "target",
"type": "number"
}
],
"return_type": "number",
"s... |
966 | vowel-spellchecker | Medium | Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word.
For a given query word, the spell checker handles two categories of spelling mistakes:
- Capitalization: If the query matches a word in the wordlist (case-insensitive), then the query word is returned with the same c... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(wordlist = ['aeiou', 'AEIOU'],queries = ['aeio', 'aeiou', 'AEIOU', 'eioua']) == ['', 'aeiou', 'AEIOU', 'aeiou']\n assert candidate(wordlist = ['aaaaa', 'Aaaaa'],queries = ['Aaaaa', 'aaaaa', 'aaAaa', 'aAaaa', 'AaAaa']) == ['Aaaaa', 'aa... | [
"[\"KiTe\",\"kite\",\"hare\",\"Hare\"]\n[\"kite\",\"Kite\",\"KiTe\",\"Hare\",\"HARE\",\"Hear\",\"hear\",\"keti\",\"keet\",\"keto\"]",
"[\"yellow\"]\n[\"YellOw\"]"
] | [] | {
"canonical_parameter_names": [
"wordlist",
"queries"
],
"leetcode_dataset_entry_point": "Solution().spellchecker",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:05",
"tests_total... | typescript | {
"raw_signature": "function spellchecker(wordlist: string[], queries: string[]): string[] {",
"container": null,
"callable": "spellchecker",
"parameters": [
{
"name": "wordlist",
"type": "string[]"
},
{
"name": "queries",
"type": "string[]"
}
],
"return_type": "strin... |
967 | numbers-with-same-consecutive-differences | Medium | Given two integers n and k, return an array of all the integers of length n where the difference between every two consecutive digits is k. You may return the answer in any order.
Note that the integers should not have leading zeros. Integers as 02 and 043 are not allowed.
Example 1:
Input: n = 3, k = 7
Output: [181... | {
"language": "python",
"source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ... | [
"3\n7",
"2\n1"
] | [] | {
"canonical_parameter_names": [
"n",
"k"
],
"leetcode_dataset_entry_point": "Solution().numsSameConsecDiff",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:07",
"tests_total": 61,
... | typescript | {
"raw_signature": "function numsSameConsecDiff(n: number, k: number): number[] {",
"container": null,
"callable": "numsSameConsecDiff",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number[]",
"signature_sou... |
969 | pancake-sorting | Medium | Given an array of integers arr, sort the array by performing a series of pancake flips.
In one pancake flip we do the following steps:
- Choose an integer k where 1 <= k <= arr.length.
- Reverse the sub-array arr[0...k-1] (0-indexed).
For example, if arr = [3,2,1,4] and we performed a pancake flip choosing k = 3, we... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [2, 1, 3, 4, 5]) == [2]\n assert candidate(arr = [4, 3, 2, 1]) == [4]\n assert candidate(arr = [5, 4, 3, 2, 1]) == [5]\n assert candidate(arr = [3, 1, 2]) == [3, 2]\n assert candidate(arr = [1, 5, 3, 4, 2]) == [2, 5, 2,... | [
"[3,2,4,1]",
"[1,2,3]"
] | [] | {
"canonical_parameter_names": [
"arr"
],
"leetcode_dataset_entry_point": "Solution().pancakeSort",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:12",
"tests_total": 99,
"tests_dropp... | typescript | {
"raw_signature": "function pancakeSort(arr: number[]): number[] {",
"container": null,
"callable": "pancakeSort",
"parameters": [
{
"name": "arr",
"type": "number[]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
970 | powerful-integers | Medium | Given three integers x, y, and bound, return a list of all the powerful integers that have a value less than or equal to bound.
An integer is powerful if it can be represented as x^i + y^j for some integers i >= 0 and j >= 0.
You may return the answer in any order. In your answer, each value should occur at most once... | {
"language": "python",
"source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ... | [
"2\n3\n10",
"3\n5\n15"
] | [] | {
"canonical_parameter_names": [
"x",
"y",
"bound"
],
"leetcode_dataset_entry_point": "Solution().powerfulIntegers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:14",
"tests_t... | typescript | {
"raw_signature": "function powerfulIntegers(x: number, y: number, bound: number): number[] {",
"container": null,
"callable": "powerfulIntegers",
"parameters": [
{
"name": "x",
"type": "number"
},
{
"name": "y",
"type": "number"
},
{
"name": "bound",
"ty... |
972 | equal-rational-numbers | Hard | Given two strings s and t, each of which represents a non-negative rational number, return true if and only if they represent the same number. The strings may use parentheses to denote the repeating part of the rational number.
A rational number can be represented using up to three parts: <IntegerPart>, <NonRepeatingP... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"0.123\",t = \"0.123\") == True\n assert candidate(s = \"0.(9)\",t = \"1\") == True\n assert candidate(s = \"0.0(0)\",t = \"0\") == True\n assert candidate(s = \"0.9(99)\",t = \"1.0\") == True\n assert candidate(s = \"0.... | [
"\"0.(52)\"\n\"0.5(25)\"",
"\"0.1666(6)\"\n\"0.166(66)\"",
"\"0.9(9)\"\n\"1.\""
] | [] | {
"canonical_parameter_names": [
"s",
"t"
],
"leetcode_dataset_entry_point": "Solution().isRationalEqual",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:18",
"tests_total": 155,
... | typescript | {
"raw_signature": "function isRationalEqual(s: string, t: string): boolean {",
"container": null,
"callable": "isRationalEqual",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "t",
"type": "string"
}
],
"return_type": "boolean",
"signature_source": "l... |
973 | k-closest-points-to-origin | Medium | Given an array of points where points[i] = [x_i, y_i] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0).
The distance between two points on the X-Y plane is the Euclidean distance (i.e., √(x_1 - x_2)^2 + (y_1 - y_2)^2).
You may return the answer in any order. The a... | {
"language": "python",
"source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ... | [
"[[1,3],[-2,2]]\n1",
"[[3,3],[5,-1],[-2,4]]\n2"
] | [] | {
"canonical_parameter_names": [
"points",
"k"
],
"leetcode_dataset_entry_point": "Solution().kClosest",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:21",
"tests_total": 98,
"te... | typescript | {
"raw_signature": "function kClosest(points: number[][], k: number): number[][] {",
"container": null,
"callable": "kClosest",
"parameters": [
{
"name": "points",
"type": "number[][]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number[][]",
"signature_s... |
974 | subarray-sums-divisible-by-k | Medium | Given an integer array nums and an integer k, return the number of non-empty subarrays that have a sum divisible by k.
A subarray is a contiguous part of an array.
Example 1:
Input: nums = [4,5,0,-2,-3,1], k = 5
Output: 7
Explanation: There are 7 subarrays with a sum divisible by k = 5:
[4, 5, 0, -2, -3, 1], [5], [5... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [2, 2, 2, 2, 2],k = 6) == 3\n assert candidate(nums = [0, 0, 0, 0],k = 2) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 25\n assert candidate(nums = [-1, 2, -3, 4, -5],k = 2) == 6\n assert ca... | [
"[4,5,0,-2,-3,1]\n5",
"[5]\n9"
] | [] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().subarraysDivByK",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:23",
"tests_total": 108,... | typescript | {
"raw_signature": "function subarraysDivByK(nums: number[], k: number): number {",
"container": null,
"callable": "subarraysDivByK",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_sou... |
975 | odd-even-jump | Hard | You are given an integer array arr. From some starting index, you can make a series of jumps. The (1^st, 3^rd, 5^th, ...) jumps in the series are called odd-numbered jumps, and the (2^nd, 4^th, 6^th, ...) jumps in the series are called even-numbered jumps. Note that the jumps are numbered, not the indices.
You may jum... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [11, 9, 7, 5, 3, 1]) == 1\n assert candidate(arr = [5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [7, 10, 5, 8, 4, 2, 6, 3, 9, 1]) == 8\n assert candidate(arr = [0, 10, 8, 9, 3, 5, 7, 6, 2, 4, 1, 11]) == 11\n assert can... | [
"[10,13,12,14,15]",
"[2,3,1,1,4]",
"[5,1,3,4,2]"
] | [] | {
"canonical_parameter_names": [
"arr"
],
"leetcode_dataset_entry_point": "Solution().oddEvenJumps",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:25",
"tests_total": 205,
"tests_dro... | typescript | {
"raw_signature": "function oddEvenJumps(arr: number[]): number {",
"container": null,
"callable": "oddEvenJumps",
"parameters": [
{
"name": "arr",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
976 | largest-perimeter-triangle | Easy | Given an integer array nums, return the largest perimeter of a triangle with a non-zero area, formed from three of these lengths. If it is impossible to form any triangle of a non-zero area, return 0.
Example 1:
Input: nums = [2,1,2]
Output: 5
Explanation: You can form a triangle with three side lengths: 1, 2, and 2.... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [10, 5, 7]) == 22\n assert candidate(nums = [10, 5, 1, 8, 12, 10, 5, 15]) == 37\n assert candidate(nums = [7, 10, 5, 2, 8, 7]) == 25\n assert candidate(nums = [1, 1, 1, 1]) == 3\n assert candidate(nums = [1, 1, 1]) == ... | [
"[2,1,2]",
"[1,2,1,10]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().largestPerimeter",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:27",
"tests_total": 114,
"test... | typescript | {
"raw_signature": "function largestPerimeter(nums: number[]): number {",
"container": null,
"callable": "largestPerimeter",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
977 | squares-of-a-sorted-array | Easy | Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.
Example 1:
Input: nums = [-4,-1,0,3,10]
Output: [0,1,9,16,100]
Explanation: After squaring, the array becomes [16,1,0,9,100].
After sorting, it becomes [0,1,9,16,100].
Example 2:
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [-2, -1, 0, 1, 2]) == [0, 1, 1, 4, 4]\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == [0, 1, 4, 9, 16, 25]\n assert candidate(nums = [-1, -1, 0, 0, 1, 1]) == [0, 0, 1, 1, 1, 1]\n assert candidate(nums = [-1]) == [1]\n ... | [
"[-4,-1,0,3,10]",
"[-7,-3,2,3,11]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().sortedSquares",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:29",
"tests_total": 119,
"tests_d... | typescript | {
"raw_signature": "function sortedSquares(nums: number[]): number[] {",
"container": null,
"callable": "sortedSquares",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
978 | longest-turbulent-subarray | Medium | Given an integer array arr, return the length of a maximum size turbulent subarray of arr.
A subarray is turbulent if the comparison sign flips between each adjacent pair of elements in the subarray.
More formally, a subarray [arr[i], arr[i + 1], ..., arr[j]] of arr is said to be turbulent if and only if:
- For i <=... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [9, 9]) == 1\n assert candidate(arr = [9, 4, 2, 10, 7, 8, 8, 1, 9]) == 5\n assert candidate(arr = [9, 8, 7, 6, 7, 8, 9, 8, 7, 6]) == 3\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 3]) == 8\n assert candidate(arr = ... | [
"[9,4,2,10,7,8,8,1,9]",
"[4,8,12,16]",
"[100]"
] | [] | {
"canonical_parameter_names": [
"arr"
],
"leetcode_dataset_entry_point": "Solution().maxTurbulenceSize",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:31",
"tests_total": 150,
"test... | typescript | {
"raw_signature": "function maxTurbulenceSize(arr: number[]): number {",
"container": null,
"callable": "maxTurbulenceSize",
"parameters": [
{
"name": "arr",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
980 | unique-paths-iii | Hard | You are given an m x n integer array grid where grid[i][j] could be:
- 1 representing the starting square. There is exactly one starting square.
- 2 representing the ending square. There is exactly one ending square.
- 0 representing empty squares we can walk over.
- -1 representing obstacles that we cannot walk over.... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[0, 1], [2, 0]]) == 0\n assert candidate(grid = [[0, 0, 0], [1, 0, 0], [0, 2, -1]]) == 0\n assert candidate(grid = [[1, 0, -1, 0, 2]]) == 0\n assert candidate(grid = [[1, 0, 2], [-1, 0, 0], [0, 0, 0]]) == 0\n assert c... | [
"[[1,0,0,0],[0,0,0,0],[0,0,2,-1]]",
"[[1,0,0,0],[0,0,0,0],[0,0,0,2]]",
"[[0,1],[2,0]]"
] | [] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().uniquePathsIII",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:36",
"tests_total": 85,
"tests_d... | typescript | {
"raw_signature": "function uniquePathsIII(grid: number[][]): number {",
"container": null,
"callable": "uniquePathsIII",
"parameters": [
{
"name": "grid",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
982 | triples-with-bitwise-and-equal-to-zero | Hard | Given an integer array nums, return the number of AND triples.
An AND triple is a triple of indices (i, j, k) such that:
- 0 <= i < nums.length
- 0 <= j < nums.length
- 0 <= k < nums.length
- nums[i] & nums[j] & nums[k] == 0, where & represents the bitwise-AND operator.
Example 1:
Input: nums = [2,1,3]
Output: 12
E... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [0, 0, 0]) == 27\n assert candidate(nums = [5, 3, 7, 10]) == 18\n assert candidate(nums = [15, 15, 15, 15]) == 0\n assert candidate(nums = [5, 3, 0, 1, 4]) == 91\n assert candidate(nums = [1, 2, 3, 4]) == 48\n asser... | [
"[2,1,3]",
"[0,0,0]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countTriplets",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:38",
"tests_total": 91,
"tests_dr... | typescript | {
"raw_signature": "function countTriplets(nums: number[]): number {",
"container": null,
"callable": "countTriplets",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
983 | minimum-cost-for-tickets | Medium | You have planned some train traveling one year in advance. The days of the year in which you will travel are given as an integer array days. Each day is an integer from 1 to 365.
Train tickets are sold in three different ways:
- a 1-day pass is sold for costs[0] dollars,
- a 7-day pass is sold for costs[1] dollars, a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(days = [1, 50, 100, 200, 300, 365],costs = [5, 10, 20]) == 30\n assert candidate(days = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31],costs = [4, 12, 30]) == 34\n assert candidate(days = [1, 100, 20... | [
"[1,4,6,7,8,20]\n[2,7,15]",
"[1,2,3,4,5,6,7,8,9,10,30,31]\n[2,7,15]"
] | [] | {
"canonical_parameter_names": [
"days",
"costs"
],
"leetcode_dataset_entry_point": "Solution().mincostTickets",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:40",
"tests_total": 7... | typescript | {
"raw_signature": "function mincostTickets(days: number[], costs: number[]): number {",
"container": null,
"callable": "mincostTickets",
"parameters": [
{
"name": "days",
"type": "number[]"
},
{
"name": "costs",
"type": "number[]"
}
],
"return_type": "number",
"sig... |
984 | string-without-aaa-or-bbb | Medium | Given two integers a and b, return any string s such that:
- s has length a + b and contains exactly a 'a' letters, and exactly b 'b' letters,
- The substring 'aaa' does not occur in s, and
- The substring 'bbb' does not occur in s.
Example 1:
Input: a = 1, b = 2
Output: "abb"
Explanation: "abb", "bab" and "bba" are... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(a = 0,b = 5) == \"bbbbb\"\n assert candidate(a = 10,b = 10) == \"abababababababababab\"\n assert candidate(a = 6,b = 4) == \"aabaababab\"\n assert candidate(a = 7,b = 7) == \"ababababababab\"\n assert candidate(a = 4,b = 1) =... | [
"1\n2",
"4\n1"
] | [] | {
"canonical_parameter_names": [
"a",
"b"
],
"leetcode_dataset_entry_point": "Solution().strWithout3a3b",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:43",
"tests_total": 64,
"t... | typescript | {
"raw_signature": "function strWithout3a3b(a: number, b: number): string {",
"container": null,
"callable": "strWithout3a3b",
"parameters": [
{
"name": "a",
"type": "number"
},
{
"name": "b",
"type": "number"
}
],
"return_type": "string",
"signature_source": "leetc... |
985 | sum-of-even-numbers-after-queries | Medium | You are given an integer array nums and an array queries where queries[i] = [val_i, index_i].
For each query i, first, apply nums[index_i] = nums[index_i] + val_i, then print the sum of the even values of nums.
Return an integer array answer where answer[i] is the answer to the i^th query.
Example 1:
Input: nums = ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [2, 4, 6, 8],queries = [[1, 0], [2, 1], [3, 2], [4, 3]]) == [18, 20, 14, 18]\n assert candidate(nums = [2, 4, 6, 8],queries = [[-2, 0], [2, 1], [-4, 2], [4, 3]]) == [18, 20, 16, 20]\n assert candidate(nums = [0, 0, 0, 0],que... | [
"[1,2,3,4]\n[[1,0],[-3,1],[-4,0],[2,3]]",
"[1]\n[[4,0]]"
] | [] | {
"canonical_parameter_names": [
"nums",
"queries"
],
"leetcode_dataset_entry_point": "Solution().sumEvenAfterQueries",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:45",
"tests_to... | typescript | {
"raw_signature": "function sumEvenAfterQueries(nums: number[], queries: number[][]): number[] {",
"container": null,
"callable": "sumEvenAfterQueries",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "queries",
"type": "number[][]"
}
],
"return_typ... |
986 | interval-list-intersections | Medium | You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [start_i, end_i] and secondList[j] = [start_j, end_j]. Each list of intervals is pairwise disjoint and in sorted order.
Return the intersection of these two interval lists.
A closed interval [a, b] (with a <= b) denotes the se... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(firstList = [[1, 2], [3, 5], [6, 7]],secondList = [[2, 3], [5, 6]]) == [[2, 2], [3, 3], [5, 5], [6, 6]]\n assert candidate(firstList = [[1, 5]],secondList = [[2, 3]]) == [[2, 3]]\n assert candidate(firstList = [],secondList = [[1, ... | [
"[[0,2],[5,10],[13,23],[24,25]]\n[[1,5],[8,12],[15,24],[25,26]]",
"[[1,3],[5,9]]\n[]"
] | [] | {
"canonical_parameter_names": [
"firstList",
"secondList"
],
"leetcode_dataset_entry_point": "Solution().intervalIntersection",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:47",
... | typescript | {
"raw_signature": "function intervalIntersection(firstList: number[][], secondList: number[][]): number[][] {",
"container": null,
"callable": "intervalIntersection",
"parameters": [
{
"name": "firstList",
"type": "number[][]"
},
{
"name": "secondList",
"type": "number[][]"
... |
989 | add-to-array-form-of-integer | Easy | The array-form of an integer num is an array representing its digits in left to right order.
- For example, for num = 1321, the array form is [1,3,2,1].
Given num, the array-form of an integer, and an integer k, return the array-form of the integer num + k.
Example 1:
Input: num = [1,2,0,0], k = 34
Output: [1,2,3,4... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = [1],k = 9) == [1, 0]\n assert candidate(num = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(num = [0],k = 10000) == [1, ... | [
"[1,2,0,0]\n34",
"[2,7,4]\n181",
"[2,1,5]\n806"
] | [] | {
"canonical_parameter_names": [
"num",
"k"
],
"leetcode_dataset_entry_point": "Solution().addToArrayForm",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:54",
"tests_total": 75,
... | typescript | {
"raw_signature": "function addToArrayForm(num: number[], k: number): number[] {",
"container": null,
"callable": "addToArrayForm",
"parameters": [
{
"name": "num",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number[]",
"signature_sou... |
990 | satisfiability-of-equality-equations | Medium | You are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one of two different forms: "x_i==y_i" or "x_i!=y_i".Here, x_i and y_i are lowercase letters (not necessarily different) that represent one-letter variable names.
Return tr... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(equations = ['a!=a']) == False\n assert candidate(equations = ['a==b', 'c==d', 'e==f', 'g==h']) == True\n assert candidate(equations = ['c==c', 'b==d', 'x!=z']) == True\n assert candidate(equations = ['a==b', 'b==c', 'a!=c']) ==... | [
"[\"a==b\",\"b!=a\"]",
"[\"b==a\",\"a==b\"]"
] | [] | {
"canonical_parameter_names": [
"equations"
],
"leetcode_dataset_entry_point": "Solution().equationsPossible",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:56",
"tests_total": 83,
... | typescript | {
"raw_signature": "function equationsPossible(equations: string[]): boolean {",
"container": null,
"callable": "equationsPossible",
"parameters": [
{
"name": "equations",
"type": "string[]"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "l... |
991 | broken-calculator | Medium | There is a broken calculator that has the integer startValue on its display initially. In one operation, you can:
- multiply the number on display by 2, or
- subtract 1 from the number on display.
Given two integers startValue and target, return the minimum number of operations needed to display target on the calcula... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(startValue = 2,target = 3) == 2\n assert candidate(startValue = 1000000000,target = 1) == 999999999\n assert candidate(startValue = 7,target = 15) == 6\n assert candidate(startValue = 2,target = 1) == 1\n assert candidate(sta... | [
"2\n3",
"5\n8",
"3\n10"
] | [] | {
"canonical_parameter_names": [
"startValue",
"target"
],
"leetcode_dataset_entry_point": "Solution().brokenCalc",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:06:58",
"tests_total"... | typescript | {
"raw_signature": "function brokenCalc(startValue: number, target: number): number {",
"container": null,
"callable": "brokenCalc",
"parameters": [
{
"name": "startValue",
"type": "number"
},
{
"name": "target",
"type": "number"
}
],
"return_type": "number",
"signa... |
992 | subarrays-with-k-different-integers | Hard | Given an integer array nums and an integer k, return the number of good subarrays of nums.
A good array is an array where the number of different integers in that array is exactly k.
- For example, [1,2,3,1,2] has 3 different integers: 1, 2, and 3.
A subarray is a contiguous part of an array.
Example 1:
Input: num... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 1, 3, 4],k = 3) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 55\n assert candidate(nums = [1, 2, 2, 1, 1, 3],k = 2) ... | [
"[1,2,1,2,3]\n2",
"[1,2,1,3,4]\n3"
] | [
"Try generating all possible subarrays and check for the number of unique integers. Increment the count accordingly.",
"How about using a map to store the count of integers?",
"Think about the Sliding Window and 2-pointer approach."
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().subarraysWithKDistinct",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:00",
"tests_total... | typescript | {
"raw_signature": "function subarraysWithKDistinct(nums: number[], k: number): number {",
"container": null,
"callable": "subarraysWithKDistinct",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
... |
994 | rotting-oranges | Medium | You are given an m x n grid where each cell can have one of three values:
- 0 representing an empty cell,
- 1 representing a fresh orange, or
- 2 representing a rotten orange.
Every minute, any fresh orange that is 4-directionally adjacent to a rotten orange becomes rotten.
Return the minimum number of minutes that ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == -1\n assert candidate(grid = [[1, 2, 1, 1, 2, 1, 1]]) == 2\n assert candidate(grid = [[2, 2, 2], [2, 1, 2], [2, 2, 2]]) == 1\n assert candidate(grid = [[2, 1, 1], [0, 1, 1], [1, 0, 1]... | [
"[[2,1,1],[1,1,0],[0,1,1]]",
"[[2,1,1],[0,1,1],[1,0,1]]",
"[[0,2]]"
] | [] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().orangesRotting",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:04",
"tests_total": 96,
"tests_d... | typescript | {
"raw_signature": "function orangesRotting(grid: number[][]): number {",
"container": null,
"callable": "orangesRotting",
"parameters": [
{
"name": "grid",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
995 | minimum-number-of-k-consecutive-bit-flips | Hard | You are given a binary array nums and an integer k.
A k-bit flip is choosing a subarray of length k from nums and simultaneously changing every 0 in the subarray to 1, and every 1 in the subarray to 0.
Return the minimum number of k-bit flips required so that there is no 0 in the array. If it is not possible, return ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [0, 0, 1, 1, 0, 1, 1, 0, 1, 0],k = 2) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == 3\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0],k = 4) == 4\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1],... | [
"[0,1,0]\n1",
"[1,1,0]\n2",
"[0,0,0,1,0,1,1,0]\n3"
] | [] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().minKBitFlips",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:07",
"tests_total": 100,
... | typescript | {
"raw_signature": "function minKBitFlips(nums: number[], k: number): number {",
"container": null,
"callable": "minKBitFlips",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": ... |
996 | number-of-squareful-arrays | Hard | An array is squareful if the sum of every pair of adjacent elements is a perfect square.
Given an integer array nums, return the number of permutations of nums that are squareful.
Two permutations perm1 and perm2 are different if there is some index i such that perm1[i] != perm2[i].
Example 1:
Input: nums = [1,17,8... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [9, 0, 16, 25, 36]) == 0\n assert candidate(nums = [2, 2, 2]) == 1\n assert candidate(nums = [1, 17, 8]) == 2\n assert candidate(nums = [9, 0, 9]) == 1\n assert candidate(nums = [0, 0, 0]) == 1\n assert candidate(nu... | [
"[1,17,8]",
"[2,2,2]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().numSquarefulPerms",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:09",
"tests_total": 109,
"tes... | typescript | {
"raw_signature": "function numSquarefulPerms(nums: number[]): number {",
"container": null,
"callable": "numSquarefulPerms",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
997 | find-the-town-judge | Easy | In a town, there are n people labeled from 1 to n. There is a rumor that one of these people is secretly the town judge.
If the town judge exists, then:
1. The town judge trusts nobody.
2. Everybody (except for the town judge) trusts the town judge.
3. There is exactly one person that satisfies properties 1 and 2.
Y... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 4,trust = [[1, 3], [1, 4], [2, 3], [2, 4], [4, 3]]) == 3\n assert candidate(n = 1,trust = []) == 1\n assert candidate(n = 5,trust = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == -1\n assert candidate(n = 3,trust = [[1, 3], [2... | [
"2\n[[1,2]]",
"3\n[[1,3],[2,3]]",
"3\n[[1,3],[2,3],[3,1]]"
] | [] | {
"canonical_parameter_names": [
"n",
"trust"
],
"leetcode_dataset_entry_point": "Solution().findJudge",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:11",
"tests_total": 86,
"te... | typescript | {
"raw_signature": "function findJudge(n: number, trust: number[][]): number {",
"container": null,
"callable": "findJudge",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "trust",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": ... |
999 | available-captures-for-rook | Easy | You are given an 8 x 8 matrix representing a chessboard. There is exactly one white rook represented by 'R', some number of white bishops 'B', and some number of black pawns 'p'. Empty squares are represented by '.'.
A rook can move any number of squares horizontally or vertically (up, down, left, right) until it reac... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.'], ['p', 'p', '.', 'R', '.', 'p', 'B', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'B... | [
"[[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"p\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"R\",\".\",\".\",\".\",\"p\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"p\",\".\",\".\",\".\",\".\"],[\".\",\".\",\... | [] | {
"canonical_parameter_names": [
"board"
],
"leetcode_dataset_entry_point": "Solution().numRookCaptures",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:16",
"tests_total": 58,
"tests... | typescript | {
"raw_signature": "function numRookCaptures(board: string[][]): number {",
"container": null,
"callable": "numRookCaptures",
"parameters": [
{
"name": "board",
"type": "string[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
1,000 | minimum-cost-to-merge-stones | Hard | There are n piles of stones arranged in a row. The i^th pile has stones[i] stones.
A move consists of merging exactly k consecutive piles into one pile, and the cost of this move is equal to the total number of stones in these k piles.
Return the minimum cost to merge all piles of stones into one pile. If it is impos... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == -1\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 2) == 135\n assert candidate(stones = [3, 2, 4, 1],k = 3) == -1\n assert candidate(stones = [1, 2, 3, 4, 5],k = 3)... | [
"[3,2,4,1]\n2",
"[3,2,4,1]\n3",
"[3,5,1,2,6]\n3"
] | [] | {
"canonical_parameter_names": [
"stones",
"k"
],
"leetcode_dataset_entry_point": "Solution().mergeStones",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:18",
"tests_total": 235,
... | typescript | {
"raw_signature": "function mergeStones(stones: number[], k: number): number {",
"container": null,
"callable": "mergeStones",
"parameters": [
{
"name": "stones",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source"... |
1,001 | grid-illumination | Hard | There is a 2D grid of size n x n where each cell of this grid has a lamp that is initially turned off.
You are given a 2D array of lamp positions lamps, where lamps[i] = [row_i, col_i] indicates that the lamp at grid[row_i][col_i] is turned on. Even if the same lamp is listed more than once, it is turned on.
When a l... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 5,lamps = [[0, 0], [4, 4]],queries = [[1, 1], [1, 1]]) == [1, 1]\n assert candidate(n = 5,lamps = [[0, 0], [0, 4]],queries = [[0, 4], [0, 1], [1, 4]]) == [1, 1, 0]\n assert candidate(n = 5,lamps = [[0, 0], [4, 4]],queries = [[1... | [
"5\n[[0,0],[4,4]]\n[[1,1],[1,0]]",
"5\n[[0,0],[4,4]]\n[[1,1],[1,1]]",
"5\n[[0,0],[0,4]]\n[[0,4],[0,1],[1,4]]"
] | [] | {
"canonical_parameter_names": [
"n",
"lamps",
"queries"
],
"leetcode_dataset_entry_point": "Solution().gridIllumination",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:20",
"t... | typescript | {
"raw_signature": "function gridIllumination(n: number, lamps: number[][], queries: number[][]): number[] {",
"container": null,
"callable": "gridIllumination",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "lamps",
"type": "number[][]"
},
{
"nam... |
1,002 | find-common-characters | Easy | Given a string array words, return an array of all characters that show up in all strings within the words (including duplicates). You may return the answer in any order.
Example 1:
Input: words = ["bella","label","roller"]
Output: ["e","l","l"]
Example 2:
Input: words = ["cool","lock","cook"]
Output: ["c","o"]
Co... | {
"language": "python",
"source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ... | [
"[\"bella\",\"label\",\"roller\"]",
"[\"cool\",\"lock\",\"cook\"]"
] | [] | {
"canonical_parameter_names": [
"words"
],
"leetcode_dataset_entry_point": "Solution().commonChars",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:22",
"tests_total": 103,
"tests_dr... | typescript | {
"raw_signature": "function commonChars(words: string[]): string[] {",
"container": null,
"callable": "commonChars",
"parameters": [
{
"name": "words",
"type": "string[]"
}
],
"return_type": "string[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
1,003 | check-if-word-is-valid-after-substitutions | Medium | Given a string s, determine if it is valid.
A string s is valid if, starting with an empty string t = "", you can transform t into s after performing the following operation any number of times:
- Insert string "abc" into any position in t. More formally, t becomes t_left + "abc" + t_right, where t == t_left + t_righ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"aaabbbccc\") == False\n assert candidate(s = \"aababcbccabc\") == False\n assert candidate(s = \"cababc\") == False\n assert candidate(s = \"abcabcabc\") == True\n assert candidate(s = \"aababcbabc\") == False\n asse... | [
"\"aabcbc\"",
"\"abcabcababcc\"",
"\"abccba\""
] | [] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().isValid",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:24",
"tests_total": 140,
"tests_dropped": ... | typescript | {
"raw_signature": "function isValid(s: string): boolean {",
"container": null,
"callable": "isValid",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,004 | max-consecutive-ones-iii | Medium | Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's.
Example 1:
Input: nums = [1,1,1,0,0,0,1,1,1,1,0], k = 2
Output: 6
Explanation: [1,1,1,0,0,1,1,1,1,1,1]
Bolded numbers were flipped from 0 to 1. The longest subarray is underlined.
Exam... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0],k = 2) == 4\n assert candidate(nums = [0, 0, 0, 0],k = 2) == 2\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0],k = 2) == 5\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1... | [
"[1,1,1,0,0,0,1,1,1,1,0]\n2",
"[0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1]\n3"
] | [
"One thing's for sure, we will only flip a zero if it extends an existing window of 1s. Otherwise, there's no point in doing it, right? Think Sliding Window!",
"Since we know this problem can be solved using the sliding window construct, we might as well focus in that direction for hints. Basically, in a given wi... | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().longestOnes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:26",
"tests_total": 77,
"t... | typescript | {
"raw_signature": "function longestOnes(nums: number[], k: number): number {",
"container": null,
"callable": "longestOnes",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "l... |
1,005 | maximize-sum-of-array-after-k-negations | Easy | Given an integer array nums and an integer k, modify the array in the following way:
- choose an index i and replace nums[i] with -nums[i].
You should apply this process exactly k times. You may choose the same index i multiple times.
Return the largest possible sum of the array after modifying it in this way.
Exam... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [-5, -4, -3, -2, -1],k = 5) == 15\n assert candidate(nums = [0, 0, 0, 0],k = 3) == 0\n assert candidate(nums = [4, 2, 3],k = 1) == 5\n assert candidate(nums = [100, -100, 50, -50],k = 3) == 200\n assert candidate(nums ... | [
"[4,2,3]\n1",
"[3,-1,0,2]\n3",
"[2,-3,-1,5,-4]\n2"
] | [] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().largestSumAfterKNegations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:29",
"tests_to... | typescript | {
"raw_signature": "function largestSumAfterKNegations(nums: number[], k: number): number {",
"container": null,
"callable": "largestSumAfterKNegations",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "numbe... |
1,006 | clumsy-factorial | Medium | The factorial of a positive integer n is the product of all positive integers less than or equal to n.
- For example, factorial(10) = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1.
We make a clumsy factorial using the integers in decreasing order by swapping out the multiply operations for a fixed rotation of operations wit... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 8) == 9\n assert candidate(n = 3) == 6\n assert candidate(n = 100) == 101\n assert candidate(n = 4) == 7\n assert candidate(n = 10000) == 10001\n assert candidate(n = 9) == 11\n assert candidate(n = 5000) == 5001\n ... | [
"4",
"10"
] | [] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().clumsy",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:31",
"tests_total": 38,
"tests_dropped": 0,... | typescript | {
"raw_signature": "function clumsy(n: number): number {",
"container": null,
"callable": "clumsy",
"parameters": [
{
"name": "n",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,007 | minimum-domino-rotations-for-equal-row | Medium | In a row of dominoes, tops[i] and bottoms[i] represent the top and bottom halves of the i^th domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.)
We may rotate the i^th domino, so that tops[i] and bottoms[i] swap values.
Return the minimum number of rotations so that all the value... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(tops = [2, 3, 2, 2],bottoms = [1, 2, 2, 2]) == 1\n assert candidate(tops = [2, 3, 2, 1, 2],bottoms = [1, 2, 3, 2, 2]) == 2\n assert candidate(tops = [6, 6, 6, 6, 6, 6],bottoms = [6, 6, 6, 6, 6, 6]) == 0\n assert candidate(tops =... | [
"[2,1,2,4,2,2]\n[5,2,6,2,3,2]",
"[3,5,1,2,3]\n[3,6,3,3,4]"
] | [] | {
"canonical_parameter_names": [
"tops",
"bottoms"
],
"leetcode_dataset_entry_point": "Solution().minDominoRotations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:33",
"tests_tot... | typescript | {
"raw_signature": "function minDominoRotations(tops: number[], bottoms: number[]): number {",
"container": null,
"callable": "minDominoRotations",
"parameters": [
{
"name": "tops",
"type": "number[]"
},
{
"name": "bottoms",
"type": "number[]"
}
],
"return_type": "num... |
1,009 | complement-of-base-10-integer | Easy | The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation.
- For example, The integer 5 is "101" in binary and its complement is "010" which is the integer 2.
Given an integer n, return its complement.
Example 1:
Input: n = 5
Output: 2
E... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 0) == 1\n assert candidate(n = 8) == 7\n assert candidate(n = 100) == 27\n assert candidate(n = 15) == 0\n assert candidate(n = 31) == 0\n assert candidate(n = 123456789) == 10760938\n assert candidate(n = 1) == 0\n... | [
"5",
"7",
"10"
] | [
"A binary number plus its complement will equal 111....111 in binary. Also, N = 0 is a corner case."
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().bitwiseComplement",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:37",
"tests_total": 37,
"tests_d... | typescript | {
"raw_signature": "function bitwiseComplement(n: number): number {",
"container": null,
"callable": "bitwiseComplement",
"parameters": [
{
"name": "n",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
1,010 | pairs-of-songs-with-total-durations-divisible-by-60 | Medium | You are given a list of songs where the i^th song has a duration of time[i] seconds.
Return the number of pairs of songs for which their total duration in seconds is divisible by 60. Formally, we want the number of indices i, j such that i < j with (time[i] + time[j]) % 60 == 0.
Example 1:
Input: time = [30,20,150,1... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(time = [1, 3, 5, 7, 9, 11]) == 0\n assert candidate(time = [40, 20, 50, 30, 10]) == 2\n assert candidate(time = [60, 120, 180, 240, 300]) == 10\n assert candidat... | [
"[30,20,150,100,40]",
"[60,60,60]"
] | [
"We only need to consider each song length modulo 60.",
"We can count the number of songs having same (length % 60), and store that in an array of size 60."
] | {
"canonical_parameter_names": [
"time"
],
"leetcode_dataset_entry_point": "Solution().numPairsDivisibleBy60",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:40",
"tests_total": 89,
"... | typescript | {
"raw_signature": "function numPairsDivisibleBy60(time: number[]): number {",
"container": null,
"callable": "numPairsDivisibleBy60",
"parameters": [
{
"name": "time",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetc... |
1,011 | capacity-to-ship-packages-within-d-days | Medium | A conveyor belt has packages that must be shipped from one port to another within days days.
The i^th package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(weights = [10, 50, 100, 100, 50, 10],days = 2) == 160\n assert candidate(weights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],days = 5) == 15\n assert candidate(weights = [10, 50, 100, 100, 50, 10],days = 3) == 160\n assert candidate(weigh... | [
"[1,2,3,4,5,6,7,8,9,10]\n5",
"[3,2,2,4,1,4]\n3",
"[1,2,3,1,1]\n4"
] | [
"Binary search on the answer. We need a function possible(capacity) which returns true if and only if we can do the task in D days."
] | {
"canonical_parameter_names": [
"weights",
"days"
],
"leetcode_dataset_entry_point": "Solution().shipWithinDays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:42",
"tests_total":... | typescript | {
"raw_signature": "function shipWithinDays(weights: number[], days: number): number {",
"container": null,
"callable": "shipWithinDays",
"parameters": [
{
"name": "weights",
"type": "number[]"
},
{
"name": "days",
"type": "number"
}
],
"return_type": "number",
"sig... |
1,012 | numbers-with-repeated-digits | Hard | Given an integer n, return the number of positive integers in the range [1, n] that have at least one repeated digit.
Example 1:
Input: n = 20
Output: 1
Explanation: The only positive number (<= 20) with at least 1 repeated digit is 11.
Example 2:
Input: n = 100
Output: 10
Explanation: The positive numbers (<= 100)... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 99999) == 67509\n assert candidate(n = 999999999) == 994388229\n assert candidate(n = 9999999) == 9287109\n assert candidate(n = 100) == 10\n assert candidate(n = 56789) == 37493\n assert candidate(n = 1000) == 262\n ... | [
"20",
"100",
"1000"
] | [
"How many numbers with no duplicate digits? How many numbers with K digits and no duplicates?",
"How many numbers with same length as N? How many numbers with same prefix as N?"
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().numDupDigitsAtMostN",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:44",
"tests_total": 59,
"tests... | typescript | {
"raw_signature": "function numDupDigitsAtMostN(n: number): number {",
"container": null,
"callable": "numDupDigitsAtMostN",
"parameters": [
{
"name": "n",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
1,013 | partition-array-into-three-parts-with-equal-sum | Easy | Given an array of integers arr, return true if we can partition the array into three non-empty parts with equal sums.
Formally, we can partition the array if we can find indexes i + 1 < j with (arr[0] + arr[1] + ... + arr[i] == arr[i + 1] + arr[i + 2] + ... + arr[j - 1] == arr[j] + arr[j + 1] + ... + arr[arr.length - ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == False\n assert candidate(arr = [10, -10, 10, -10, 10, -10, ... | [
"[0,2,1,-6,6,-7,9,1,2,0,1]",
"[0,2,1,-6,6,7,9,-1,2,0,1]",
"[3,3,6,5,-2,2,5,1,-9,4]"
] | [
"If we have three parts with the same sum, what is the sum of each? If you can find the first part, can you find the second part?"
] | {
"canonical_parameter_names": [
"arr"
],
"leetcode_dataset_entry_point": "Solution().canThreePartsEqualSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:46",
"tests_total": 77,
"t... | typescript | {
"raw_signature": "function canThreePartsEqualSum(arr: number[]): boolean {",
"container": null,
"callable": "canThreePartsEqualSum",
"parameters": [
{
"name": "arr",
"type": "number[]"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetc... |
1,014 | best-sightseeing-pair | Medium | You are given an integer array values where values[i] represents the value of the i^th sightseeing spot. Two sightseeing spots i and j have a distance j - i between them.
The score of a pair (i < j) of sightseeing spots is values[i] + values[j] + i - j: the sum of the values of the sightseeing spots, minus the distanc... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(values = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 1998\n assert candidate(values = [1, 3, 5, 7, 9, 11]) == 19\n assert candidate(values = [10, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 10\n assert candidate(values = [1, 100,... | [
"[8,1,5,2,6]",
"[1,2]"
] | [
"Can you tell the best sightseeing spot in one pass (ie. as you iterate over the input?) What should we store or keep track of as we iterate to do this?"
] | {
"canonical_parameter_names": [
"values"
],
"leetcode_dataset_entry_point": "Solution().maxScoreSightseeingPair",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:48",
"tests_total": 106... | typescript | {
"raw_signature": "function maxScoreSightseeingPair(values: number[]): number {",
"container": null,
"callable": "maxScoreSightseeingPair",
"parameters": [
{
"name": "values",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source"... |
1,015 | smallest-integer-divisible-by-k | Medium | Given a positive integer k, you need to find the length of the smallest positive integer n such that n is divisible by k, and n only contains the digit 1.
Return the length of n. If there is no such n, return -1.
Note: n may not fit in a 64-bit signed integer.
Example 1:
Input: k = 1
Output: 1
Explanation: The smal... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(k = 29) == 28\n assert candidate(k = 101) == 4\n assert candidate(k = 83) == 41\n assert candidate(k = 43) == 21\n assert candidate(k = 89) == 44\n assert candidate(k = 17) == 16\n assert candidate(k = 73) == 8\n ass... | [
"1",
"2",
"3"
] | [
"11111 = 1111 * 10 + 1 We only need to store remainders modulo K.",
"If we never get a remainder of 0, why would that happen, and how would we know that?"
] | {
"canonical_parameter_names": [
"k"
],
"leetcode_dataset_entry_point": "Solution().smallestRepunitDivByK",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:51",
"tests_total": 90,
"tes... | typescript | {
"raw_signature": "function smallestRepunitDivByK(k: number): number {",
"container": null,
"callable": "smallestRepunitDivByK",
"parameters": [
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
1,016 | binary-string-with-substrings-representing-1-to-n | Medium | Given a binary string s and a positive integer n, return true if the binary representation of all the integers in the range [1, n] are substrings of s, or false otherwise.
A substring is a contiguous sequence of characters within a string.
Example 1:
Input: s = "0110", n = 3
Output: true
Example 2:
Input: s = "011... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"0110\",n = 3) == True\n assert candidate(s = \"1111111111\",n = 10) == False\n assert candidate(s = \"0000000000\",n = 1) == False\n assert candidate(s = \"0110\",n = 4) == False\n assert candidate(s = \"000000\",n = 1)... | [
"\"0110\"\n3",
"\"0110\"\n4"
] | [
"We only need to check substrings of length at most 30, because 10^9 has 30 bits."
] | {
"canonical_parameter_names": [
"s",
"n"
],
"leetcode_dataset_entry_point": "Solution().queryString",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:53",
"tests_total": 96,
"test... | typescript | {
"raw_signature": "function queryString(s: string, n: number): boolean {",
"container": null,
"callable": "queryString",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "n",
"type": "number"
}
],
"return_type": "boolean",
"signature_source": "leetcode/... |
1,017 | convert-to-base-2 | Medium | Given an integer n, return a binary string representing its representation in base -2.
Note that the returned string should not have leading zeros unless the string is "0".
Example 1:
Input: n = 2
Output: "110"
Explantion: (-2)^2 + (-2)^1 = 2
Example 2:
Input: n = 3
Output: "111"
Explantion: (-2)^2 + (-2)^1 + (-2)... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 3) == \"111\"\n assert candidate(n = 104730) == \"1101110100101101110\"\n assert candidate(n = 100) == \"110100100\"\n assert candidate(n = 1000) == \"10000111000\"\n assert candidate(n = 5) == \"101\"\n assert candida... | [
"2",
"3",
"4"
] | [
"Figure out whether you need the ones digit placed or not, then shift by two."
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().baseNeg2",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:55",
"tests_total": 69,
"tests_dropped": ... | typescript | {
"raw_signature": "function baseNeg2(n: number): string {",
"container": null,
"callable": "baseNeg2",
"parameters": [
{
"name": "n",
"type": "number"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,018 | binary-prefix-divisible-by-5 | Easy | You are given a binary array nums (0-indexed).
We define x_i as the number whose binary representation is the subarray nums[0..i] (from most-significant-bit to least-significant-bit).
- For example, if nums = [1,0,1], then x_0 = 1, x_1 = 2, and x_2 = 5.
Return an array of booleans answer where answer[i] is true if x... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1]) == [False]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [True, False, False, True, True, False, False, True, True, False]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [False, False, False... | [
"[0,1,1]",
"[1,1,1]"
] | [
"If X is the first i digits of the array as a binary number, then 2X + A[i] is the first i+1 digits."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().prefixesDivBy5",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:07:57",
"tests_total": 69,
"tests_d... | typescript | {
"raw_signature": "function prefixesDivBy5(nums: number[]): boolean[] {",
"container": null,
"callable": "prefixesDivBy5",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "boolean[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
1,020 | number-of-enclaves | Medium | You are given an m x n binary matrix grid, where 0 represents a sea cell and 1 represents a land cell.
A move consists of walking from one land cell to another adjacent (4-directionally) land cell or walking off the boundary of the grid.
Return the number of land cells in grid for which we cannot walk off the boundar... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[0, 0, 0, 0], [1, 0, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 3\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 0], [0, 0, 1, 0], [0, 0, 1, 0], [0,... | [
"[[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]]",
"[[0,1,1,0],[0,0,1,0],[0,0,1,0],[0,0,0,0]]"
] | [
"Can you model this problem as a graph problem? Create n * m + 1 nodes where n * m nodes represents each cell of the map and one extra node to represent the exterior of the map.",
"In the map add edges between neighbors on land cells. And add edges between the exterior and land nodes which are in the boundary. Re... | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().numEnclaves",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:01",
"tests_total": 67,
"tests_drop... | typescript | {
"raw_signature": "function numEnclaves(grid: number[][]): number {",
"container": null,
"callable": "numEnclaves",
"parameters": [
{
"name": "grid",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
1,021 | remove-outermost-parentheses | Easy | A valid parentheses string is either empty "", "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation.
- For example, "", "()", "(())()", and "(()(()))" are all valid parentheses strings.
A valid parentheses string s is primitive if it is nonempty, and there does n... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"(()(()))()\") == \"()(())\"\n assert candidate(s = \"()\") == \"\"\n assert candidate(s = \"()(()())\") == \"()()\"\n assert candidate(s = \"(()())(())\") == \"()()()\"\n assert candidate(s = \"((()))\") == \"(())\"\n ... | [
"\"(()())(())\"",
"\"(()())(())(()(()))\"",
"\"()()\""
] | [
"Can you find the primitive decomposition? The number of ( and ) characters must be equal."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().removeOuterParentheses",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:04",
"tests_total": 103,
"t... | typescript | {
"raw_signature": "function removeOuterParentheses(s: string): string {",
"container": null,
"callable": "removeOuterParentheses",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
1,023 | camelcase-matching | Medium | Given an array of strings queries and a string pattern, return a boolean array answer where answer[i] is true if queries[i] matches pattern, and false otherwise.
A query word queries[i] matches pattern if you can insert lowercase English letters into the pattern so that it equals the query. You may insert a character ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(queries = ['FooBar', 'FooBarTest', 'FootBall', 'FrameBuffer', 'ForceFeedBack'],pattern = \"FB\") == [True, False, True, True, False]\n assert candidate(queries = ['FooBar', 'FooBarTest', 'FootBall', 'FrameBuffer', 'ForceFeedBack'],pat... | [
"[\"FooBar\",\"FooBarTest\",\"FootBall\",\"FrameBuffer\",\"ForceFeedBack\"]\n\"FB\"",
"[\"FooBar\",\"FooBarTest\",\"FootBall\",\"FrameBuffer\",\"ForceFeedBack\"]\n\"FoBa\"",
"[\"FooBar\",\"FooBarTest\",\"FootBall\",\"FrameBuffer\",\"ForceFeedBack\"]\n\"FoBaT\""
] | [
"Given a single pattern and word, how can we solve it?",
"One way to do it is using a DP (pos1, pos2) where pos1 is a pointer to the word and pos2 to the pattern and returns true if we can match the pattern with the given word.",
"We have two scenarios: The first one is when `word[pos1] == pattern[pos2]`, then ... | {
"canonical_parameter_names": [
"queries",
"pattern"
],
"leetcode_dataset_entry_point": "Solution().camelMatch",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:08",
"tests_total": ... | typescript | {
"raw_signature": "function camelMatch(queries: string[], pattern: string): boolean[] {",
"container": null,
"callable": "camelMatch",
"parameters": [
{
"name": "queries",
"type": "string[]"
},
{
"name": "pattern",
"type": "string"
}
],
"return_type": "boolean[]",
... |
1,024 | video-stitching | Medium | You are given a series of video clips from a sporting event that lasted time seconds. These video clips can be overlapping with each other and have varying lengths.
Each video clip is described by an array clips where clips[i] = [start_i, end_i] indicates that the ith clip started at start_i and ended at end_i.
We ca... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(clips = [[0, 5], [0, 7], [1, 3], [1, 4], [2, 5], [2, 6], [3, 4], [3, 5], [4, 5], [4, 6], [5, 6], [5, 7], [6, 7], [6, 8], [7, 8], [7, 10], [7, 9], [8, 10], [9, 10]],time = 10) == 2\n assert candidate(clips = [[0, 2], [4, 6], [8, 10], [... | [
"[[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]]\n10",
"[[0,1],[1,2]]\n5",
"[[0,1],[6,8],[0,2],[5,6],[0,4],[0,3],[6,7],[1,3],[4,7],[1,4],[2,5],[2,6],[3,4],[4,5],[5,7],[6,9]]\n9"
] | [
"What if we sort the intervals? Considering the sorted intervals, how can we solve the problem with dynamic programming?",
"Let's consider a DP(pos, limit) where pos represents the position of the current interval we are gonna take the decision and limit is the current covered area from [0 - limit]. This DP retur... | {
"canonical_parameter_names": [
"clips",
"time"
],
"leetcode_dataset_entry_point": "Solution().videoStitching",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:10",
"tests_total": 9... | typescript | {
"raw_signature": "function videoStitching(clips: number[][], time: number): number {",
"container": null,
"callable": "videoStitching",
"parameters": [
{
"name": "clips",
"type": "number[][]"
},
{
"name": "time",
"type": "number"
}
],
"return_type": "number",
"sig... |
1,025 | divisor-game | Easy | Alice and Bob take turns playing a game, with Alice starting first.
Initially, there is a number n on the chalkboard. On each player's turn, that player makes a move consisting of:
- Choosing any integer x with 0 < x < n and n % x == 0.
- Replacing the number n on the chalkboard with n - x.
Also, if a player cannot ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 8) == True\n assert candidate(n = 3) == False\n assert candidate(n = 4) == True\n assert candidate(n = 9) == False\n assert candidate(n = 6) == True\n assert candidate(n = 2) == True\n assert candidate(n = 1000) == ... | [
"2",
"3"
] | [
"If the current number is even, we can always subtract a 1 to make it odd. If the current number is odd, we must subtract an odd number to make it even."
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().divisorGame",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:12",
"tests_total": 51,
"tests_dropped... | typescript | {
"raw_signature": "function divisorGame(n: number): boolean {",
"container": null,
"callable": "divisorGame",
"parameters": [
{
"name": "n",
"type": "number"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,027 | longest-arithmetic-subsequence | Medium | Given an array nums of integers, return the length of the longest arithmetic subsequence in nums.
Note that:
- A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.
- A sequence seq is arithmetic if seq[i + 1] - seq[i] ar... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 11, 11, 11, 15]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 8\n assert candidate(nums = [83, 20, 17, 43, 52, 78, 68, 45]) == 2\n assert candidate(nums = [8, 12, 16, 20, 24, 28]) == 6\n ass... | [
"[3,6,9,12]",
"[9,4,7,2,10]",
"[20,1,15,3,10,5,8]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().longestArithSeqLength",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:17",
"tests_total": 159,
... | typescript | {
"raw_signature": "function longestArithSeqLength(nums: number[]): number {",
"container": null,
"callable": "longestArithSeqLength",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetc... |
1,029 | two-city-scheduling | Medium | A company is planning to interview 2n people. Given the array costs where costs[i] = [aCost_i, bCost_i], the cost of flying the i^th person to city a is aCost_i, and the cost of flying the i^th person to city b is bCost_i.
Return the minimum cost to fly every person to a city such that exactly n people arrive in each ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(costs = [[30, 20], [200, 300], [50, 400], [20, 30]]) == 300\n assert candidate(costs = [[10, 20], [30, 200], [400, 50], [30, 20]]) == 110\n assert candidate(costs = [[515, 563], [451, 713], [537, 709], [343, 819], [855, 779], [457,... | [
"[[10,20],[30,200],[400,50],[30,20]]",
"[[259,770],[448,54],[926,667],[184,139],[840,118],[577,469]]",
"[[515,563],[451,713],[537,709],[343,819],[855,779],[457,60],[650,359],[631,42]]"
] | [] | {
"canonical_parameter_names": [
"costs"
],
"leetcode_dataset_entry_point": "Solution().twoCitySchedCost",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:22",
"tests_total": 68,
"test... | typescript | {
"raw_signature": "function twoCitySchedCost(costs: number[][]): number {",
"container": null,
"callable": "twoCitySchedCost",
"parameters": [
{
"name": "costs",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
1,030 | matrix-cells-in-distance-order | Easy | You are given four integers row, cols, rCenter, and cCenter. There is a rows x cols matrix and you are on the cell with the coordinates (rCenter, cCenter).
Return the coordinates of all cells in the matrix, sorted by their distance from (rCenter, cCenter) from the smallest distance to the largest distance. You may ret... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(rows = 5,cols = 7,rCenter = 3,cCenter = 4) == [[3, 4], [2, 4], [3, 5], [4, 4], [3, 3], [1, 4], [2, 5], [2, 3], [3, 6], [4, 5], [4, 3], [3, 2], [0, 4], [1, 5], [1, 3], [2, 6], [2, 2], [4, 6], [4, 2], [3, 1], [0, 5], [0, 3], [1, 6], [1, 2]... | [
"1\n2\n0\n0",
"2\n2\n0\n1",
"2\n3\n1\n2"
] | [] | {
"canonical_parameter_names": [
"rows",
"cols",
"rCenter",
"cCenter"
],
"leetcode_dataset_entry_point": "Solution().allCellsDistOrder",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-... | typescript | {
"raw_signature": "function allCellsDistOrder(rows: number, cols: number, rCenter: number, cCenter: number): number[][] {",
"container": null,
"callable": "allCellsDistOrder",
"parameters": [
{
"name": "rows",
"type": "number"
},
{
"name": "cols",
"type": "number"
},
... |
1,031 | maximum-sum-of-two-non-overlapping-subarrays | Medium | Given an integer array nums and two integers firstLen and secondLen, return the maximum sum of elements in two non-overlapping subarrays with lengths firstLen and secondLen.
The array with length firstLen could occur before or after the array with length secondLen, but they have to be non-overlapping.
A subarray is a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1],firstLen = 3,secondLen = 3) == 6\n assert candidate(nums = [0, 6, 5, 2, 2, 5, 1, 9, 4],firstLen = 1,secondLen = 2) == 20\n assert candidate(nums = [2, 1, 5, 6, 0, 9, 5, 0, 3, 8],firstLen = 4,secon... | [
"[0,6,5,2,2,5,1,9,4]\n1\n2",
"[3,8,1,3,2,1,8,9,0]\n3\n2",
"[2,1,5,6,0,9,5,0,3,8]\n4\n3"
] | [
"We can use prefix sums to calculate any subarray sum quickly. For each L length subarray, find the best possible M length subarray that occurs before and after it."
] | {
"canonical_parameter_names": [
"nums",
"firstLen",
"secondLen"
],
"leetcode_dataset_entry_point": "Solution().maxSumTwoNoOverlap",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08... | typescript | {
"raw_signature": "function maxSumTwoNoOverlap(nums: number[], firstLen: number, secondLen: number): number {",
"container": null,
"callable": "maxSumTwoNoOverlap",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "firstLen",
"type": "number"
},
{
... |
1,033 | moving-stones-until-consecutive | Medium | There are three stones in different positions on the X-axis. You are given three integers a, b, and c, the positions of the stones.
In one move, you pick up a stone at an endpoint (i.e., either the lowest or highest position stone), and move it to an unoccupied position between those endpoints. Formally, let's say the... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(a = 7,b = 8,c = 10) == [1, 1]\n assert candidate(a = 1,b = 100,c = 50) == [2, 97]\n assert candidate(a = 1,b = 3,c = 100) == [1, 97]\n assert candidate(a = 10,b = 12,c = 14) == [1, 2]\n assert candidate(a = 50,b = 51,c = 53) ... | [
"1\n2\n5",
"4\n3\n2",
"3\n5\n1"
] | [
"For the minimum: We can always do it in at most 2 moves, by moving one stone next to another, then the third stone next to the other two. When can we do it in 1 move? 0 moves? For the maximum: Every move, the maximum position minus the minimum position must decrease by at least 1."
] | {
"canonical_parameter_names": [
"a",
"b",
"c"
],
"leetcode_dataset_entry_point": "Solution().numMovesStones",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:28",
"tests_total":... | typescript | {
"raw_signature": "function numMovesStones(a: number, b: number, c: number): number[] {",
"container": null,
"callable": "numMovesStones",
"parameters": [
{
"name": "a",
"type": "number"
},
{
"name": "b",
"type": "number"
},
{
"name": "c",
"type": "number... |
1,034 | coloring-a-border | Medium | You are given an m x n integer matrix grid, and three integers row, col, and color. Each value in the grid represents the color of the grid square at that location.
Two squares are called adjacent if they are next to each other in any of the 4 directions.
Two squares belong to the same connected component if they hav... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[1000, 1000, 1000], [1000, 1, 1000], [1000, 1000, 1000]],row = 1,col = 1,color = 2) == [[1000, 1000, 1000], [1000, 2, 1000], [1000, 1000, 1000]]\n assert candidate(grid = [[1, 1], [1, 2]],row = 0,col = 0,color = 3) == [[3, 3],... | [
"[[1,1],[1,2]]\n0\n0\n3",
"[[1,2,2],[2,3,2]]\n0\n1\n3",
"[[1,1,1],[1,1,1],[1,1,1]]\n1\n1\n2"
] | [
"Use a DFS to find every square in the component. Then for each square, color it if it has a neighbor that is outside the grid or a different color."
] | {
"canonical_parameter_names": [
"grid",
"row",
"col",
"color"
],
"leetcode_dataset_entry_point": "Solution().colorBorder",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:31",... | typescript | {
"raw_signature": "function colorBorder(grid: number[][], row: number, col: number, color: number): number[][] {",
"container": null,
"callable": "colorBorder",
"parameters": [
{
"name": "grid",
"type": "number[][]"
},
{
"name": "row",
"type": "number"
},
{
"na... |
1,035 | uncrossed-lines | Medium | You are given two integer arrays nums1 and nums2. We write the integers of nums1 and nums2 (in the order they are given) on two separate horizontal lines.
We may draw connecting lines: a straight line connecting two numbers nums1[i] and nums2[j] such that:
- nums1[i] == nums2[j], and
- the line we draw does not inter... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums1 = [2, 5, 1, 2, 5],nums2 = [10, 5, 2, 1, 5, 2]) == 3\n assert candidate(nums1 = [1, 4, 2],nums2 = [1, 2, 4]) == 2\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3],nums2 = [3, 3, 3, 3, 3, 3, 3]) == 7\n assert candidate(nums1... | [
"[1,4,2]\n[1,2,4]",
"[2,5,1,2,5]\n[10,5,2,1,5,2]",
"[1,3,7,1,7,5]\n[1,9,2,5,1]"
] | [
"Think dynamic programming. Given an oracle dp(i,j) that tells us how many lines A[i:], B[j:] [the sequence A[i], A[i+1], ... and B[j], B[j+1], ...] are uncrossed, can we write this as a recursion?"
] | {
"canonical_parameter_names": [
"nums1",
"nums2"
],
"leetcode_dataset_entry_point": "Solution().maxUncrossedLines",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:33",
"tests_total... | typescript | {
"raw_signature": "function maxUncrossedLines(nums1: number[], nums2: number[]): number {",
"container": null,
"callable": "maxUncrossedLines",
"parameters": [
{
"name": "nums1",
"type": "number[]"
},
{
"name": "nums2",
"type": "number[]"
}
],
"return_type": "number"... |
1,036 | escape-a-large-maze | Hard | There is a 1 million by 1 million grid on an XY-plane, and the coordinates of each grid square are (x, y).
We start at the source = [s_x, s_y] square and want to reach the target = [t_x, t_y] square. There is also an array of blocked squares, where each blocked[i] = [x_i, y_i] represents a blocked square with coordina... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(blocked = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],source = [0, 0],target = [6, 6]) == True\n assert candidate(blocked = [[5, 5]],source = [4, 4],target = [6, 6]) == True\n assert candidate(blocked =... | [
"[[0,1],[1,0]]\n[0,0]\n[0,2]",
"[]\n[0,0]\n[999999,999999]"
] | [
"If we become stuck, there's either a loop around the source or around the target.",
"If there is a loop around say, the source, what is the maximum number of squares it can have?"
] | {
"canonical_parameter_names": [
"blocked",
"source",
"target"
],
"leetcode_dataset_entry_point": "Solution().isEscapePossible",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:35"... | typescript | {
"raw_signature": "function isEscapePossible(blocked: number[][], source: number[], target: number[]): boolean {",
"container": null,
"callable": "isEscapePossible",
"parameters": [
{
"name": "blocked",
"type": "number[][]"
},
{
"name": "source",
"type": "number[]"
},
... |
1,037 | valid-boomerang | Easy | Given an array points where points[i] = [x_i, y_i] represents a point on the X-Y plane, return true if these points are a boomerang.
A boomerang is a set of three points that are all distinct and not in a straight line.
Example 1:
Input: points = [[1,1],[2,3],[3,2]]
Output: true
Example 2:
Input: points = [[1,1],[... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(points = [[1, 1], [2, 2], [1, 3]]) == True\n assert candidate(points = [[1, 1], [2, 5], [3, 9]]) == False\n assert candidate(points = [[1, 1], [2, 3], [3, 2]]) == True\n assert candidate(points = [[5, 5], [6, 6], [7, 7]]) == Fal... | [
"[[1,1],[2,3],[3,2]]",
"[[1,1],[2,2],[3,3]]"
] | [
"3 points form a boomerang if and only if the triangle formed from them has non-zero area."
] | {
"canonical_parameter_names": [
"points"
],
"leetcode_dataset_entry_point": "Solution().isBoomerang",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:37",
"tests_total": 116,
"tests_d... | typescript | {
"raw_signature": "function isBoomerang(points: number[][]): boolean {",
"container": null,
"callable": "isBoomerang",
"parameters": [
{
"name": "points",
"type": "number[][]"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
1,039 | minimum-score-triangulation-of-polygon | Medium | You have a convex n-sided polygon where each vertex has an integer value. You are given an integer array values where values[i] is the value of the i^th vertex in clockwise order.
Polygon triangulation is a process where you divide a polygon into a set of triangles and the vertices of each triangle must also be vertic... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(values = [10, 1, 1, 10]) == 110\n assert candidate(values = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 328\n assert candidate(values = [3, 1, 2, 4, 5, 6]) == 76\n assert candidate(values = [10, 1, 20, 2, 30, 3, 40, 4]) == 510\n asse... | [
"[1,2,3]",
"[3,7,4,5]",
"[1,3,1,4,1,5]"
] | [
"Without loss of generality, there is a triangle that uses adjacent vertices A[0] and A[N-1] (where N = A.length). Depending on your choice K of it, this breaks down the triangulation into two subproblems A[1:K] and A[K+1:N-1]."
] | {
"canonical_parameter_names": [
"values"
],
"leetcode_dataset_entry_point": "Solution().minScoreTriangulation",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:42",
"tests_total": 111,
... | typescript | {
"raw_signature": "function minScoreTriangulation(values: number[]): number {",
"container": null,
"callable": "minScoreTriangulation",
"parameters": [
{
"name": "values",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "l... |
1,040 | moving-stones-until-consecutive-ii | Medium | There are some stones in different positions on the X-axis. You are given an integer array stones, the positions of the stones.
Call a stone an endpoint stone if it has the smallest or largest position. In one move, you pick up an endpoint stone and move it to an unoccupied position so that it is no longer an endpoint... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(stones = [4, 5, 6, 7, 100]) == [2, 92]\n assert candidate(stones = [10, 11, 12, 14, 15, 16]) == [1, 1]\n assert candidate(stones = [3, 6, 9, 12, 15]) == [3, 6]\n assert candidate(stones = [6, 5, 4, 3, 10]) == [2, 3]\n assert ... | [
"[7,4,9]",
"[6,5,4,3,10]"
] | [
"For the minimum, how many stones are already in place? For the maximum, we have to lose either the gap A[1] - A[0] or A[N-1] - A[N-2] (where N = A.length), but every other space can be occupied."
] | {
"canonical_parameter_names": [
"stones"
],
"leetcode_dataset_entry_point": "Solution().numMovesStonesII",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:44",
"tests_total": 140,
"te... | typescript | {
"raw_signature": "function numMovesStonesII(stones: number[]): number[] {",
"container": null,
"callable": "numMovesStonesII",
"parameters": [
{
"name": "stones",
"type": "number[]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcod... |
1,041 | robot-bounded-in-circle | Medium | On an infinite plane, a robot initially stands at (0, 0) and faces north. Note that:
- The north direction is the positive direction of the y-axis.
- The south direction is the negative direction of the y-axis.
- The east direction is the positive direction of the x-axis.
- The west direction is the negative direction... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(instructions = \"GGLGRGLL\") == True\n assert candidate(instructions = \"LLLL\") == True\n assert candidate(instructions = \"GLLRLLRL\") == True\n assert candidate(instructions = \"GRGL\") == False\n assert candidate(instruct... | [
"\"GGLLGG\"",
"\"GG\"",
"\"GL\""
] | [
"Calculate the final vector of how the robot travels after executing all instructions once - it consists of a change in position plus a change in direction.",
"The robot stays in the circle if and only if (looking at the final vector) it changes direction (ie. doesn't stay pointing north), or it moves 0."
] | {
"canonical_parameter_names": [
"instructions"
],
"leetcode_dataset_entry_point": "Solution().isRobotBounded",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:46",
"tests_total": 140,
... | typescript | {
"raw_signature": "function isRobotBounded(instructions: string): boolean {",
"container": null,
"callable": "isRobotBounded",
"parameters": [
{
"name": "instructions",
"type": "string"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetc... |
1,042 | flower-planting-with-no-adjacent | Medium | You have n gardens, labeled from 1 to n, and an array paths where paths[i] = [x_i, y_i] describes a bidirectional path between garden x_i to garden y_i. In each garden, you want to plant one of 4 types of flowers.
All gardens have at most 3 paths coming into or leaving it.
Your task is to choose a flower type for eac... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 3,paths = [[1, 2], [2, 3], [3, 1]]) == [1, 2, 3]\n assert candidate(n = 6,paths = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 6], [4, 5], [4, 6]]) == [1, 2, 2, 2, 1, 1]\n assert candidate(n = 6,paths = [[1, 2], [2, 3],... | [
"3\n[[1,2],[2,3],[3,1]]",
"4\n[[1,2],[3,4]]",
"4\n[[1,2],[2,3],[3,4],[4,1],[1,3],[2,4]]"
] | [
"Since each garden is connected to at most 3 gardens, there's always an available color for each garden. For example, if one garden is next to gardens with colors 1, 3, 4, then color #2 is available."
] | {
"canonical_parameter_names": [
"n",
"paths"
],
"leetcode_dataset_entry_point": "Solution().gardenNoAdj",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:48",
"tests_total": 59,
"... | typescript | {
"raw_signature": "function gardenNoAdj(n: number, paths: number[][]): number[] {",
"container": null,
"callable": "gardenNoAdj",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "paths",
"type": "number[][]"
}
],
"return_type": "number[]",
"signature_s... |
1,043 | partition-array-for-maximum-sum | Medium | Given an integer array arr, partition the array into (contiguous) subarrays of length at most k. After partitioning, each subarray has their values changed to become the maximum value of that subarray.
Return the largest sum of the given array after partitioning. Test cases are generated so that the answer fits in a 3... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [1],k = 1) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 1) == 45\n assert candidate(arr = [1, 15, 7, 9, 2, 5, 10],k = 3) == 84\n assert candidate(arr = [10, 20, 30, 40, 50],k = 3) == 190\n assert candid... | [
"[1,15,7,9,2,5,10]\n3",
"[1,4,1,5,7,3,6,1,9,9,3]\n4",
"[1]\n1"
] | [
"Think dynamic programming: dp[i] will be the answer for array A[0], ..., A[i-1].",
"For j = 1 .. k that keeps everything in bounds, dp[i] is the maximum of dp[i-j] + max(A[i-1], ..., A[i-j]) * j ."
] | {
"canonical_parameter_names": [
"arr",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxSumAfterPartitioning",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:50",
"tests_total... | typescript | {
"raw_signature": "function maxSumAfterPartitioning(arr: number[], k: number): number {",
"container": null,
"callable": "maxSumAfterPartitioning",
"parameters": [
{
"name": "arr",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
... |
1,044 | longest-duplicate-substring | Hard | Given a string s, consider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap.
Return any duplicated substring that has the longest possible length. If s does not have a duplicated substring, the answer is "".
Example 1:
Input: s = "banana"
Output: "ana"
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abcabcabc\") == \"abcabc\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz... | [
"\"banana\"",
"\"abcd\""
] | [
"Binary search for the length of the answer. (If there's an answer of length 10, then there are answers of length 9, 8, 7, ...)",
"To check whether an answer of length K exists, we can use Rabin-Karp 's algorithm."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().longestDupSubstring",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:53",
"tests_total": 117,
"test... | typescript | {
"raw_signature": "function longestDupSubstring(s: string): string {",
"container": null,
"callable": "longestDupSubstring",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
1,046 | last-stone-weight | Easy | You are given an array of integers stones where stones[i] is the weight of the i^th stone.
We are playing a game with the stones. On each turn, we choose the heaviest two stones and smash them together. Suppose the heaviest two stones have weights x and y with x <= y. The result of this smash is:
- If x == y, both st... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(stones = [9, 3, 2, 10, 8]) == 2\n assert candidate(stones = [5, 5, 5, 5, 5]) == 5\n assert candidate(stones = [5, 5, 5, 5, 5]) == 5\n assert candidate(stones = [3, 3, 3, 3, 3]) == 3\n assert candidate(stones = [10, 9, 8, 7, 6... | [
"[2,7,4,1,8,1]",
"[1]"
] | [
"Simulate the process. We can do it with a heap, or by sorting some list of stones every time we take a turn."
] | {
"canonical_parameter_names": [
"stones"
],
"leetcode_dataset_entry_point": "Solution().lastStoneWeight",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:55",
"tests_total": 124,
"tes... | typescript | {
"raw_signature": "function lastStoneWeight(stones: number[]): number {",
"container": null,
"callable": "lastStoneWeight",
"parameters": [
{
"name": "stones",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
1,047 | remove-all-adjacent-duplicates-in-string | Easy | You are given a string s consisting of lowercase English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing them.
We repeatedly make duplicate removals on s until we no longer can.
Return the final string after all such duplicate removals have been made. It can be proven tha... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"acbbcaa\") == \"a\"\n assert candidate(s = \"aabbaa\") == \"\"\n assert candidate(s = \"abcdef\") == \"abcdef\"\n assert candidate... | [
"\"abbaca\"",
"\"azxxzy\""
] | [
"Use a stack to process everything greedily."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().removeDuplicates",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:08:57",
"tests_total": 42,
"tests_dr... | typescript | {
"raw_signature": "function removeDuplicates(s: string): string {",
"container": null,
"callable": "removeDuplicates",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,048 | longest-string-chain | Medium | You are given an array of words where each word consists of lowercase English letters.
word_A is a predecessor of word_B if and only if we can insert exactly one letter anywhere in word_A without changing the order of the other characters to make it equal to word_B.
- For example, "abc" is a predecessor of "abac", wh... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(words = ['xbc', 'pcxbcf', 'xb', 'cxbc', 'pcxbc']) == 5\n assert candidate(words = ['a', 'b', 'ba', 'bca', 'bda', 'bdca']) == 4\n assert candidate(words = ['abcd', 'abde', 'acde', 'bcde', 'abcde']) == 2\n assert candidate(words =... | [
"[\"a\",\"b\",\"ba\",\"bca\",\"bda\",\"bdca\"]",
"[\"xbc\",\"pcxbcf\",\"xb\",\"cxbc\",\"pcxbc\"]",
"[\"abcd\",\"dbqca\"]"
] | [
"Instead of adding a character, try deleting a character to form a chain in reverse.",
"For each word in order of length, for each word2 which is word with one character removed, length[word2] = max(length[word2], length[word] + 1)."
] | {
"canonical_parameter_names": [
"words"
],
"leetcode_dataset_entry_point": "Solution().longestStrChain",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:09:00",
"tests_total": 84,
"tests... | typescript | {
"raw_signature": "function longestStrChain(words: string[]): number {",
"container": null,
"callable": "longestStrChain",
"parameters": [
{
"name": "words",
"type": "string[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
1,049 | last-stone-weight-ii | Medium | You are given an array of integers stones where stones[i] is the weight of the i^th stone.
We are playing a game with the stones. On each turn, we choose any two stones and smash them together. Suppose the stones have weights x and y with x <= y. The result of this smash is:
- If x == y, both stones are destroyed, an... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(stones = [10, 10, 10, 10, 10]) == 10\n assert candidate(stones = [3, 9, 7, 3]) == 2\n assert candidate(stones = [1, 2, 3, 4, 5]) == 1\n assert candidate(stones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,... | [
"[2,7,4,1,8,1]",
"[31,26,33,21,40]"
] | [
"Think of the final answer as a sum of weights with + or - sign symbols infront of each weight. Actually, all sums with 1 of each sign symbol are possible.",
"Use dynamic programming: for every possible sum with N stones, those sums +x or -x is possible with N+1 stones, where x is the value of the newest stone. (... | {
"canonical_parameter_names": [
"stones"
],
"leetcode_dataset_entry_point": "Solution().lastStoneWeightII",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:09:02",
"tests_total": 99,
"te... | typescript | {
"raw_signature": "function lastStoneWeightII(stones: number[]): number {",
"container": null,
"callable": "lastStoneWeightII",
"parameters": [
{
"name": "stones",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
1,051 | height-checker | Easy | A school is trying to take an annual photo of all the students. The students are asked to stand in a single file line in non-decreasing order by height. Let this ordering be represented by the integer array expected where expected[i] is the expected height of the i^th student in line.
You are given an integer array he... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(heights = [1]) == 0\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(heights = [1, 2, 1, 2]) == 2\n assert candidate(heights = [3, 3, 3, 3, 3]) == 0\n assert candidate(heights = [1, 2, 3,... | [
"[1,1,4,2,1,3]",
"[5,1,2,3,4]",
"[1,2,3,4,5]"
] | [
"Build the correct order of heights by sorting another array, then compare the two arrays."
] | {
"canonical_parameter_names": [
"heights"
],
"leetcode_dataset_entry_point": "Solution().heightChecker",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:09:04",
"tests_total": 115,
"test... | typescript | {
"raw_signature": "function heightChecker(heights: number[]): number {",
"container": null,
"callable": "heightChecker",
"parameters": [
{
"name": "heights",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
1,052 | grumpy-bookstore-owner | Medium | There is a bookstore owner that has a store open for n minutes. You are given an integer array customers of length n where customers[i] is the number of the customers that enter the store at the start of the i^th minute and all those customers leave after the end of that minute.
During certain minutes, the bookstore o... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(customers = [3, 1, 4, 2, 2],grumpy = [0, 0, 1, 1, 1],minutes = 1) == 8\n assert candidate(customers = [5, 5, 5, 5, 5],grumpy = [0, 0, 0, 0, 0],minutes = 1) == 25\n assert candidate(customers = [2, 3, 4, 5],grumpy = [1, 0, 1, 1],min... | [
"[1,0,1,2,1,1,7,5]\n[0,1,0,1,0,1,0,1]\n3",
"[1]\n[0]\n1"
] | [
"Say the store owner uses their power in minute 1 to X and we have some answer A. If they instead use their power from minute 2 to X+1, we only have to use data from minutes 1, 2, X and X+1 to update our answer A."
] | {
"canonical_parameter_names": [
"customers",
"grumpy",
"minutes"
],
"leetcode_dataset_entry_point": "Solution().maxSatisfied",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:09:06",... | typescript | {
"raw_signature": "function maxSatisfied(customers: number[], grumpy: number[], minutes: number): number {",
"container": null,
"callable": "maxSatisfied",
"parameters": [
{
"name": "customers",
"type": "number[]"
},
{
"name": "grumpy",
"type": "number[]"
},
{
... |
1,053 | previous-permutation-with-one-swap | Medium | Given an array of positive integers arr (not necessarily distinct), return the lexicographically largest permutation that is smaller than arr, that can be made with exactly one swap. If it cannot be done, then return the same array.
Note that a swap exchanges the positions of two numbers arr[i] and arr[j]
Example 1:
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [10, 9, 8, 7, 6, 5]) == [10, 9, 8, 7, 5, 6]\n assert candidate(arr = [3, 2, 1]) == [3, 1, 2]\n assert candidate(arr = [5, 1, 1, 2, 3]) == [3, 1, 1, 2, 5]\n assert candidate(arr = [5, 4, 3, 2, 1]) == [5, 4, 3, 1, 2]\n as... | [
"[3,2,1]",
"[1,1,5]",
"[1,9,4,6,7]"
] | [
"You need to swap two values, one larger than the other. Where is the larger one located?"
] | {
"canonical_parameter_names": [
"arr"
],
"leetcode_dataset_entry_point": "Solution().prevPermOpt1",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:09:08",
"tests_total": 140,
"tests_dro... | typescript | {
"raw_signature": "function prevPermOpt1(arr: number[]): number[] {",
"container": null,
"callable": "prevPermOpt1",
"parameters": [
{
"name": "arr",
"type": "number[]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
1,054 | distant-barcodes | Medium | In a warehouse, there is a row of barcodes, where the i^th barcode is barcodes[i].
Rearrange the barcodes so that no two adjacent barcodes are equal. You may return any answer, and it is guaranteed an answer exists.
Example 1:
Input: barcodes = [1,1,1,2,2,2]
Output: [2,1,2,1,2,1]
Example 2:
Input: barcodes = [1,1,... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(barcodes = [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5]) == [1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 2, 5, 2]\n assert candidate(barcodes = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [1, 3, 1, 4, 2, 4, 2, 5, 3, 5]\n assert candidate(barcodes = [2, 2, 1, ... | [
"[1,1,1,2,2,2]",
"[1,1,1,1,2,2,3,3]"
] | [
"We want to always choose the most common or second most common element to write next. What data structure allows us to query this effectively?"
] | {
"canonical_parameter_names": [
"barcodes"
],
"leetcode_dataset_entry_point": "Solution().rearrangeBarcodes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:09:11",
"tests_total": 96,
"... | typescript | {
"raw_signature": "function rearrangeBarcodes(barcodes: number[]): number[] {",
"container": null,
"callable": "rearrangeBarcodes",
"parameters": [
{
"name": "barcodes",
"type": "number[]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "l... |
1,061 | lexicographically-smallest-equivalent-string | Medium | You are given two strings of the same length s1 and s2 and a string baseStr.
We say s1[i] and s2[i] are equivalent characters.
- For example, if s1 = "abc" and s2 = "cde", then we have 'a' == 'c', 'b' == 'd', and 'c' == 'e'.
Equivalent characters follow the usual rules of any equivalence relation:
- Reflexivity: 'a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s1 = \"abc\",s2 = \"bcd\",baseStr = \"xyz\") == \"xyz\"\n assert candidate(s1 = \"leetcode\",s2 = \"programs\",baseStr = \"sourcecode\") == \"aauaaaaada\"\n assert candidate(s1 = \"parker\",s2 = \"morris\",baseStr = \"parser\") == ... | [
"\"parker\"\n\"morris\"\n\"parser\"",
"\"hello\"\n\"world\"\n\"hold\"",
"\"leetcode\"\n\"programs\"\n\"sourcecode\""
] | [
"Model these equalities as edges of a graph.",
"Group each connected component of the graph and assign each node of this component to the node with the lowest lexicographically character.",
"Finally convert the string with the precalculated information."
] | {
"canonical_parameter_names": [
"s1",
"s2",
"baseStr"
],
"leetcode_dataset_entry_point": "Solution().smallestEquivalentString",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:09:27"... | typescript | {
"raw_signature": "function smallestEquivalentString(s1: string, s2: string, baseStr: string): string {",
"container": null,
"callable": "smallestEquivalentString",
"parameters": [
{
"name": "s1",
"type": "string"
},
{
"name": "s2",
"type": "string"
},
{
"name"... |
1,071 | greatest-common-divisor-of-strings | Easy | For two strings s and t, we say "t divides s" if and only if s = t + t + t + ... + t + t (i.e., t is concatenated with itself one or more times).
Given two strings str1 and str2, return the largest string x such that x divides both str1 and str2.
Example 1:
Input: str1 = "ABCABC", str2 = "ABC"
Output: "ABC"
Example... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(str1 = \"ABAB\",str2 = \"ABA\") == \"\"\n assert candidate(str1 = \"ABCDEFGH\",str2 = \"XYZ\") == \"\"\n assert candidate(str1 = \"ABCABC\",str2 = \"ABC\") == \"ABC\"\n assert candidate(str1 = \"ABABAB\",str2 = \"ABA\") == \"\"\... | [
"\"ABCABC\"\n\"ABC\"",
"\"ABABAB\"\n\"ABAB\"",
"\"LEET\"\n\"CODE\"",
"\"AAAAAB\"\n\"AAA\""
] | [
"The greatest common divisor must be a prefix of each string, so we can try all prefixes."
] | {
"canonical_parameter_names": [
"str1",
"str2"
],
"leetcode_dataset_entry_point": "Solution().gcdOfStrings",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:09:42",
"tests_total": 175,... | typescript | {
"raw_signature": "function gcdOfStrings(str1: string, str2: string): string {",
"container": null,
"callable": "gcdOfStrings",
"parameters": [
{
"name": "str1",
"type": "string"
},
{
"name": "str2",
"type": "string"
}
],
"return_type": "string",
"signature_source"... |
1,072 | flip-columns-for-maximum-number-of-equal-rows | Medium | You are given an m x n binary matrix matrix.
You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the cell from 0 to 1 or vice versa).
Return the maximum number of rows that have all values equal after some number of flips.
Example 1:
Input: matrix = [[0,1... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(matrix = [[0, 1], [1, 0]]) == 2\n assert candidate(matrix = [[1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 0]]) == 3\n assert candidate(matrix = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0]]) == 2\n assert candidate(matrix = [[1, 0, 0, 1],... | [
"[[0,1],[1,1]]",
"[[0,1],[1,0]]",
"[[0,0,0],[0,0,1],[1,1,0]]"
] | [
"Flipping a subset of columns is like doing a bitwise XOR of some number K onto each row. We want rows X with X ^ K = all 0s or all 1s. This is the same as X = X^K ^K = (all 0s or all 1s) ^ K, so we want to count rows that have opposite bits set. For example, if K = 1, then we count rows X = (00000...001, or 1111..... | {
"canonical_parameter_names": [
"matrix"
],
"leetcode_dataset_entry_point": "Solution().maxEqualRowsAfterFlips",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:09:45",
"tests_total": 88,
... | typescript | {
"raw_signature": "function maxEqualRowsAfterFlips(matrix: number[][]): number {",
"container": null,
"callable": "maxEqualRowsAfterFlips",
"parameters": [
{
"name": "matrix",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_sourc... |
1,073 | adding-two-negabinary-numbers | Medium | Given two numbers arr1 and arr2 in base -2, return the result of adding them together.
Each number is given in array format: as an array of 0s and 1s, from most significant bit to least significant bit. For example, arr = [1,1,0,1] represents the number (-2)^3 + (-2)^2 + (-2)^0 = -3. A number arr in array, format is a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr1 = [0],arr2 = [0]) == [0]\n assert candidate(arr1 = [1, 0, 1, 0, 1],arr2 = [1, 0, 1, 0, 1]) == [1, 1, 1, 1, 1, 1, 0]\n assert candidate(arr1 = [1, 1, 0],arr2 = [1, 1, 0]) == [1, 0, 0]\n assert candidate(arr1 = [1, 0, 1],arr2... | [
"[1,1,1,1,1]\n[1,0,1]",
"[0]\n[0]",
"[0]\n[1]"
] | [
"We can try to determine the last digit of the answer, then divide everything by 2 and repeat."
] | {
"canonical_parameter_names": [
"arr1",
"arr2"
],
"leetcode_dataset_entry_point": "Solution().addNegabinary",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:09:47",
"tests_total": 104... | typescript | {
"raw_signature": "function addNegabinary(arr1: number[], arr2: number[]): number[] {",
"container": null,
"callable": "addNegabinary",
"parameters": [
{
"name": "arr1",
"type": "number[]"
},
{
"name": "arr2",
"type": "number[]"
}
],
"return_type": "number[]",
"sig... |
1,074 | number-of-submatrices-that-sum-to-target | Hard | Given a matrix and a target, return the number of non-empty submatrices that sum to target.
A submatrix x1, y1, x2, y2 is the set of all cells matrix[x][y] with x1 <= x <= x2 and y1 <= y <= y2.
Two submatrices (x1, y1, x2, y2) and (x1', y1', x2', y2') are different if they have some coordinate that is different: for ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(matrix = [[1]],target = 1) == 1\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6]],target = 12) == 1\n assert candidate(matrix = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]],target = -9) == 1\n assert candidate(matrix = [[0, 0, 0]... | [
"[[0,1,0],[1,1,1],[0,1,0]]\n0",
"[[1,-1],[-1,1]]\n0",
"[[904]]\n0"
] | [
"Using a 2D prefix sum, we can query the sum of any submatrix in O(1) time. Now for each (r1, r2), we can find the largest sum of a submatrix that uses every row in [r1, r2] in linear time using a sliding window."
] | {
"canonical_parameter_names": [
"matrix",
"target"
],
"leetcode_dataset_entry_point": "Solution().numSubmatrixSumTarget",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:09:49",
"tests... | typescript | {
"raw_signature": "function numSubmatrixSumTarget(matrix: number[][], target: number): number {",
"container": null,
"callable": "numSubmatrixSumTarget",
"parameters": [
{
"name": "matrix",
"type": "number[][]"
},
{
"name": "target",
"type": "number"
}
],
"return_typ... |
1,078 | occurrences-after-bigram | Easy | Given two strings first and second, consider occurrences in some text of the form "first second third", where second comes immediately after first, and third comes immediately after second.
Return an array of all the words third for each occurrence of "first second third".
Example 1:
Input: text = "alice is a good g... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(text = \"hello world hello hello world\",first = \"hello\",second = \"world\") == ['hello']\n assert candidate(text = \"repeat repeat repeat repeat\",first = \"repeat\",second = \"repeat\") == ['repeat', 'repeat']\n assert candidat... | [
"\"alice is a good girl she is a good student\"\n\"a\"\n\"good\"",
"\"we will we will rock you\"\n\"we\"\n\"will\""
] | [
"Split the string into words, then look at adjacent triples of words."
] | {
"canonical_parameter_names": [
"text",
"first",
"second"
],
"leetcode_dataset_entry_point": "Solution().findOcurrences",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:09:51",
"t... | typescript | {
"raw_signature": "function findOcurrences(text: string, first: string, second: string): string[] {",
"container": null,
"callable": "findOcurrences",
"parameters": [
{
"name": "text",
"type": "string"
},
{
"name": "first",
"type": "string"
},
{
"name": "second... |
1,079 | letter-tile-possibilities | Medium | You have n tiles, where each tile has one letter tiles[i] printed on it.
Return the number of possible non-empty sequences of letters you can make using the letters printed on those tiles.
Example 1:
Input: tiles = "AAB"
Output: 8
Explanation: The possible sequences are "A", "B", "AA", "AB", "BA", "AAB", "ABA", "BAA... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(tiles = \"AAAAAAA\") == 7\n assert candidate(tiles = \"QQQ\") == 3\n assert candidate(tiles = \"ABCDEFG\") == 13699\n assert candidate(tiles = \"ABC\") == 15\n assert candidate(tiles = \"AAB\") == 8\n assert candidate(tile... | [
"\"AAB\"",
"\"AAABBC\"",
"\"V\""
] | [
"Try to build the string with a backtracking DFS by considering what you can put in every position."
] | {
"canonical_parameter_names": [
"tiles"
],
"leetcode_dataset_entry_point": "Solution().numTilePossibilities",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:09:53",
"tests_total": 74,
"... | typescript | {
"raw_signature": "function numTilePossibilities(tiles: string): number {",
"container": null,
"callable": "numTilePossibilities",
"parameters": [
{
"name": "tiles",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
1,081 | smallest-subsequence-of-distinct-characters | Medium | Given a string s, return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once.
Example 1:
Input: s = "bcabc"
Output: "abc"
Example 2:
Input: s = "cbacdcbc"
Output: "acdb"
Constraints:
- 1 <= s.length <= 1000
- s consists of lowercase English letters.
Note: T... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"rakuqjeiaxeidqqeaeiaxqeaeiaxjeidqq\") == \"rakudeiqxj\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"cccaae\") == \"cae\"\n assert candidate(s = \"cbacdcbc\") == \"acdb\"\n assert candidate(s = \"abac... | [
"\"bcabc\"",
"\"cbacdcbc\""
] | [
"Greedily try to add one missing character. How to check if adding some character will not cause problems ? Use bit-masks to check whether you will be able to complete the sub-sequence if you add the character at some index i."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().smallestSubsequence",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:09:58",
"tests_total": 124,
"test... | typescript | {
"raw_signature": "function smallestSubsequence(s: string): string {",
"container": null,
"callable": "smallestSubsequence",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
1,090 | largest-values-from-labels | Medium | You are given n item's value and label as two integer arrays values and labels. You are also given two integers numWanted and useLimit.
Your task is to find a subset of items with the maximum sum of their values such that:
- The number of items is at most numWanted.
- The number of items with the same label is at mos... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(values = [10, 10, 10, 10],labels = [1, 1, 1, 1],numWanted = 3,useLimit = 2) == 20\n assert candidate(values = [10, 10, 10, 10],labels = [1, 2, 3, 4],numWanted = 4,useLimit = 1) == 40\n assert candidate(values = [9, 8, 8, 7, 6],labe... | [
"[5,4,3,2,1]\n[1,1,2,2,3]\n3\n1",
"[5,4,3,2,1]\n[1,3,3,3,2]\n3\n2",
"[9,8,8,7,6]\n[0,0,0,1,1]\n3\n1"
] | [
"Consider the items in order from largest to smallest value, and greedily take the items if they fall under the use_limit. We can keep track of how many items of each label are used by using a hash table."
] | {
"canonical_parameter_names": [
"values",
"labels",
"numWanted",
"useLimit"
],
"leetcode_dataset_entry_point": "Solution().largestValsFromLabels",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at"... | typescript | {
"raw_signature": "function largestValsFromLabels(values: number[], labels: number[], numWanted: number, useLimit: number): number {",
"container": null,
"callable": "largestValsFromLabels",
"parameters": [
{
"name": "values",
"type": "number[]"
},
{
"name": "labels",
"type"... |
1,091 | shortest-path-in-binary-matrix | Medium | Given an n x n binary matrix grid, return the length of the shortest clear path in the matrix. If there is no clear path, return -1.
A clear path in a binary matrix is a path from the top-left cell (i.e., (0, 0)) to the bottom-right cell (i.e., (n - 1, n - 1)) such that:
- All the visited cells of the path are 0.
- A... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[0, 1], [1, 0]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, ... | [
"[[0,1],[1,0]]",
"[[0,0,0],[1,1,0],[1,1,0]]",
"[[1,0,0],[1,1,0],[1,1,0]]"
] | [
"Do a breadth first search to find the shortest path."
] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().shortestPathBinaryMatrix",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:10:13",
"tests_total": 67,
... | typescript | {
"raw_signature": "function shortestPathBinaryMatrix(grid: number[][]): number {",
"container": null,
"callable": "shortestPathBinaryMatrix",
"parameters": [
{
"name": "grid",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_sourc... |
1,092 | shortest-common-supersequence | Hard | Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences. If there are multiple valid strings, return any of them.
A string s is a subsequence of string t if deleting some number of characters from t (possibly 0) results in the string s.
Example 1:
Input: str1 = "abac",... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(str1 = \"xyz\",str2 = \"xyx\") == \"xyxz\"\n assert candidate(str1 = \"short\",str2 = \"sorts\") == \"shorts\"\n assert candidate(str1 = \"algorithm\",str2 = \"altruistic\") == \"altgoruistichm\"\n assert candidate(str1 = \"ab\"... | [
"\"abac\"\n\"cab\"",
"\"aaaaaaaa\"\n\"aaaaaaaa\""
] | [
"We can find the length of the longest common subsequence between str1[i:] and str2[j:] (for all (i, j)) by using dynamic programming.",
"We can use this information to recover the shortest common supersequence."
] | {
"canonical_parameter_names": [
"str1",
"str2"
],
"leetcode_dataset_entry_point": "Solution().shortestCommonSupersequence",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:10:16",
"tes... | typescript | {
"raw_signature": "function shortestCommonSupersequence(str1: string, str2: string): string {",
"container": null,
"callable": "shortestCommonSupersequence",
"parameters": [
{
"name": "str1",
"type": "string"
},
{
"name": "str2",
"type": "string"
}
],
"return_type": ... |
1,094 | car-pooling | Medium | There is a car with capacity empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).
You are given the integer capacity and an array trips where trips[i] = [numPassengers_i, from_i, to_i] indicates that the i^th trip has numPassengers_i passengers and the locations to pick them up and d... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(trips = [[3, 2, 8], [4, 4, 6], [10, 8, 10]],capacity = 12) == True\n assert candidate(trips = [[3, 2, 7], [2, 7, 9], [4, 1, 3]],capacity = 6) == False\n assert candidate(trips = [[2, 1, 5], [3, 5, 7]],capacity = 5) == True\n ass... | [
"[[2,1,5],[3,3,7]]\n4",
"[[2,1,5],[3,3,7]]\n5"
] | [
"Sort the pickup and dropoff events by location, then process them in order."
] | {
"canonical_parameter_names": [
"trips",
"capacity"
],
"leetcode_dataset_entry_point": "Solution().carPooling",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:10:20",
"tests_total": 1... | typescript | {
"raw_signature": "function carPooling(trips: number[][], capacity: number): boolean {",
"container": null,
"callable": "carPooling",
"parameters": [
{
"name": "trips",
"type": "number[][]"
},
{
"name": "capacity",
"type": "number"
}
],
"return_type": "boolean",
"s... |
1,096 | brace-expansion-ii | Hard | Under the grammar given below, strings can represent a set of lowercase words. Let R(expr) denote the set of words the expression represents.
The grammar can best be understood through simple examples:
- Single letters represent a singleton set containing that word.
- R("a") = {"a"}
- R("w") = {"w"}
- When we tak... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(expression = \"a\") == ['a']\n assert candidate(expression = \"{a,bc,def}\") == ['a', 'bc', 'def']\n assert candidate(expression = \"a{b{c,d},e{f,g}}\") == ['abc', 'abd', 'aef', 'aeg']\n assert candidate(expression = \"{a,b,c}\"... | [
"\"{a,b}{c,{d,e}}\"",
"\"{{a,z},a{b,c},{ab,z}}\""
] | [
"You can write helper methods to parse the next \"chunk\" of the expression. If you see eg. \"a\", the answer is just the set {a}. If you see \"{\", you parse until you complete the \"}\" (the number of { and } seen are equal) and that becomes a chunk that you find where the appropriate commas are, and parse each i... | {
"canonical_parameter_names": [
"expression"
],
"leetcode_dataset_entry_point": "Solution().braceExpansionII",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:10:22",
"tests_total": 100,
... | typescript | {
"raw_signature": "function braceExpansionII(expression: string): string[] {",
"container": null,
"callable": "braceExpansionII",
"parameters": [
{
"name": "expression",
"type": "string"
}
],
"return_type": "string[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "lee... |
1,103 | distribute-candies-to-people | Easy | We distribute some number of candies, to a row of n = num_people people in the following way:
We then give 1 candy to the first person, 2 candies to the second person, and so on until we give n candies to the last person.
Then, we go back to the start of the row, giving n + 1 candies to the first person, n + 2 candie... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(candies = 500000000,num_people = 500) == [1008064, 1008128, 1008192, 1008256, 1008320, 1008384, 1008448, 1008512, 1008576, 1008640, 1008704, 1008768, 1008832, 1008896, 1008960, 1009024, 1009088, 1009152, 1009216, 1009280, 1009344, 100940... | [
"7\n4",
"10\n3"
] | [
"Give candy to everyone each \"turn\" first [until you can't], then give candy to one person per turn."
] | {
"canonical_parameter_names": [
"candies",
"num_people"
],
"leetcode_dataset_entry_point": "Solution().distributeCandies",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:10:33",
"test... | typescript | {
"raw_signature": "function distributeCandies(candies: number, num_people: number): number[] {",
"container": null,
"callable": "distributeCandies",
"parameters": [
{
"name": "candies",
"type": "number"
},
{
"name": "num_people",
"type": "number"
}
],
"return_type": ... |
1,104 | path-in-zigzag-labelled-binary-tree | Medium | In an infinite binary tree where every node has two children, the nodes are labelled in row order.
In the odd numbered rows (ie., the first, third, fifth,...), the labelling is left to right, while in the even numbered rows (second, fourth, sixth,...), the labelling is right to left.
Given the label of a node in this... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(label = 14) == [1, 3, 4, 14]\n assert candidate(label = 1023) == [1, 3, 4, 15, 16, 63, 64, 255, 256, 1023]\n assert candidate(label = 3) == [1, 3]\n assert candidate(label = 1000000) == [1, 3, 4, 15, 17, 61, 69, 244, 279, 976, 1... | [
"14",
"26"
] | [
"Based on the label of the current node, find what the label must be for the parent of that node."
] | {
"canonical_parameter_names": [
"label"
],
"leetcode_dataset_entry_point": "Solution().pathInZigZagTree",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:10:36",
"tests_total": 78,
"test... | typescript | {
"raw_signature": "function pathInZigZagTree(label: number): number[] {",
"container": null,
"callable": "pathInZigZagTree",
"parameters": [
{
"name": "label",
"type": "number"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
1,105 | filling-bookcase-shelves | Medium | You are given an array books where books[i] = [thickness_i, height_i] indicates the thickness and height of the i^th book. You are also given an integer shelfWidth.
We want to place these books in order onto bookcase shelves that have a total width shelfWidth.
We choose some of the books to place on this shelf such t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(books = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],shelfWidth = 1) == 10\n assert candidate(books = [[1, 1], [2, 2], [3, 3]],shelfWidth = 5) == 4\n assert candidate(books = [[10, 1], [2, 2], [3... | [
"[[1,1],[2,3],[2,3],[1,1],[1,1],[1,1],[1,2]]\n4",
"[[1,3],[2,4],[3,2]]\n6"
] | [
"Use dynamic programming: dp(i) will be the answer to the problem for books[i:]."
] | {
"canonical_parameter_names": [
"books",
"shelfWidth"
],
"leetcode_dataset_entry_point": "Solution().minHeightShelves",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:10:38",
"tests_t... | typescript | {
"raw_signature": "function minHeightShelves(books: number[][], shelfWidth: number): number {",
"container": null,
"callable": "minHeightShelves",
"parameters": [
{
"name": "books",
"type": "number[][]"
},
{
"name": "shelfWidth",
"type": "number"
}
],
"return_type": ... |
1,106 | parsing-a-boolean-expression | Hard | A boolean expression is an expression that evaluates to either true or false. It can be in one of the following shapes:
- 't' that evaluates to true.
- 'f' that evaluates to false.
- '!(subExpr)' that evaluates to the logical NOT of the inner expression subExpr.
- '&(subExpr_1, subExpr_2, ..., subExpr_n)' that evaluat... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(expression = \"!(!(t))\") == True\n assert candidate(expression = \"|(t,t,t)\") == True\n assert candidate(expression = \"|(f,f,f,t)\") == True\n assert candidate(expression = \"&(t,t,t,t,t,t)\") == True\n assert candidate(ex... | [
"\"&(|(f))\"",
"\"|(f,f,f,t)\"",
"\"!(&(f,t))\""
] | [
"Write a function \"parse\" which calls helper functions \"parse_or\", \"parse_and\", \"parse_not\"."
] | {
"canonical_parameter_names": [
"expression"
],
"leetcode_dataset_entry_point": "Solution().parseBoolExpr",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:10:40",
"tests_total": 130,
"t... | typescript | {
"raw_signature": "function parseBoolExpr(expression: string): boolean {",
"container": null,
"callable": "parseBoolExpr",
"parameters": [
{
"name": "expression",
"type": "string"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
1,108 | defanging-an-ip-address | Easy | Given a valid (IPv4) IP address, return a defanged version of that IP address.
A defanged IP address replaces every period "." with "[.]".
Example 1:
Input: address = "1.1.1.1"
Output: "1[.]1[.]1[.]1"
Example 2:
Input: address = "255.100.50.0"
Output: "255[.]100[.]50[.]0"
Constraints:
- The given address is a va... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(address = \"255.100.50.0\") == \"255[.]100[.]50[.]0\"\n assert candidate(address = \"255.255.255.255\") == \"255[.]255[.]255[.]255\"\n assert candidate(address = \"192.168.1.1\") == \"192[.]168[.]1[.]1\"\n assert candidate(addre... | [
"\"1.1.1.1\"",
"\"255.100.50.0\""
] | [] | {
"canonical_parameter_names": [
"address"
],
"leetcode_dataset_entry_point": "Solution().defangIPaddr",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:10:42",
"tests_total": 48,
"tests_... | typescript | {
"raw_signature": "function defangIPaddr(address: string): string {",
"container": null,
"callable": "defangIPaddr",
"parameters": [
{
"name": "address",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
1,109 | corporate-flight-bookings | Medium | There are n flights that are labeled from 1 to n.
You are given an array of flight bookings bookings, where bookings[i] = [first_i, last_i, seats_i] represents a booking for flights first_i through last_i (inclusive) with seats_i seats reserved for each flight in the range.
Return an array answer of length n, where a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(bookings = [[1, 2, 100], [2, 5, 50], [3, 4, 20]],n = 5) == [100, 150, 70, 70, 50]\n assert candidate(bookings = [[1, 1, 5], [1, 2, 7], [1, 3, 9]],n = 3) == [21, 16, 9]\n assert candidate(bookings = [[1, 4, 5], [4, 5, 6], [2, 5, 3]]... | [
"[[1,2,10],[2,3,20],[2,5,25]]\n5",
"[[1,2,10],[2,2,15]]\n2"
] | [] | {
"canonical_parameter_names": [
"bookings",
"n"
],
"leetcode_dataset_entry_point": "Solution().corpFlightBookings",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:10:45",
"tests_total... | typescript | {
"raw_signature": "function corpFlightBookings(bookings: number[][], n: number): number[] {",
"container": null,
"callable": "corpFlightBookings",
"parameters": [
{
"name": "bookings",
"type": "number[][]"
},
{
"name": "n",
"type": "number"
}
],
"return_type": "numbe... |
1,111 | maximum-nesting-depth-of-two-valid-parentheses-strings | Medium | A string is a valid parentheses string (denoted VPS) if and only if it consists of "(" and ")" characters only, and:
- It is the empty string, or
- It can be written as AB (A concatenated with B), where A and B are VPS's, or
- It can be written as (A), where A is a VPS.
We can similarly define the nesting depth depth... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(seq = \"()\") == [0, 0]\n assert candidate(seq = \"(()())\") == [0, 1, 1, 1, 1, 0]\n assert candidate(seq = \"(()(()(())))\") == [0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0]\n assert candidate(seq = \"((())())()\") == [0, 1, 0, 0, 1, 1,... | [
"\"(()())\"",
"\"()(())()\""
] | [] | {
"canonical_parameter_names": [
"seq"
],
"leetcode_dataset_entry_point": "Solution().maxDepthAfterSplit",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:10:47",
"tests_total": 146,
"tes... | typescript | {
"raw_signature": "function maxDepthAfterSplit(seq: string): number[] {",
"container": null,
"callable": "maxDepthAfterSplit",
"parameters": [
{
"name": "seq",
"type": "string"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
1,122 | relative-sort-array | Easy | Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1.
Sort the elements of arr1 such that the relative ordering of items in arr1 are the same as in arr2. Elements that do not appear in arr2 should be placed at the end of arr1 in ascending order.
Example 1:
Inpu... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr1 = [28, 6, 22, 8, 44, 17],arr2 = [22, 28, 8, 6]) == [22, 28, 8, 6, 17, 44]\n assert candidate(arr1 = [1, 2, 3],arr2 = [1, 2, 3, 4, 5]) == [1, 2, 3]\n assert candidate(arr1 = [10, 9, 8, 7, 6],arr2 = [10, 9, 8, 7, 6]) == [10, 9, ... | [
"[2,3,1,3,2,4,6,7,9,2,19]\n[2,1,4,3,9,6]",
"[28,6,22,8,44,17]\n[22,28,8,6]"
] | [
"Using a hashmap, we can map the values of arr2 to their position in arr2.",
"After, we can use a custom sorting function."
] | {
"canonical_parameter_names": [
"arr1",
"arr2"
],
"leetcode_dataset_entry_point": "Solution().relativeSortArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:10:58",
"tests_total":... | typescript | {
"raw_signature": "function relativeSortArray(arr1: number[], arr2: number[]): number[] {",
"container": null,
"callable": "relativeSortArray",
"parameters": [
{
"name": "arr1",
"type": "number[]"
},
{
"name": "arr2",
"type": "number[]"
}
],
"return_type": "number[]"... |
1,124 | longest-well-performing-interval | Medium | We are given hours, a list of the number of hours worked per day for a given employee.
A day is considered to be a tiring day if and only if the number of hours worked is (strictly) greater than 8.
A well-performing interval is an interval of days for which the number of tiring days is strictly larger than the number... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(hours = [9, 7, 9, 7, 9, 7, 9, 7]) == 7\n assert candidate(hours = [8, 9, 9, 10]) == 4\n assert candidate(hours = [9, 9, 9, 9, 9, 9, 9]) == 7\n assert candidate(hours = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(hour... | [
"[9,9,6,0,6,6,9]",
"[6,6,6]"
] | [
"Make a new array A of +1/-1s corresponding to if hours[i] is > 8 or not. The goal is to find the longest subarray with positive sum.",
"Using prefix sums (PrefixSum[i+1] = A[0] + A[1] + ... + A[i]), you need to find for each j, the smallest i < j with PrefixSum[i] + 1 == PrefixSum[j]."
] | {
"canonical_parameter_names": [
"hours"
],
"leetcode_dataset_entry_point": "Solution().longestWPI",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:11:02",
"tests_total": 99,
"tests_drop... | typescript | {
"raw_signature": "function longestWPI(hours: number[]): number {",
"container": null,
"callable": "longestWPI",
"parameters": [
{
"name": "hours",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,125 | smallest-sufficient-team | Hard | In a project, you have a list of required skills req_skills, and a list of people. The i^th person people[i] contains a list of skills that the person has.
Consider a sufficient team: a set of people such that for every required skill in req_skills, there is at least one person in the team who has that skill. We can r... | {
"language": "python",
"source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ... | [
"[\"java\",\"nodejs\",\"reactjs\"]\n[[\"java\"],[\"nodejs\"],[\"nodejs\",\"reactjs\"]]",
"[\"algorithms\",\"math\",\"java\",\"reactjs\",\"csharp\",\"aws\"]\n[[\"algorithms\",\"math\",\"java\"],[\"algorithms\",\"math\",\"reactjs\"],[\"java\",\"csharp\",\"aws\"],[\"reactjs\",\"csharp\"],[\"csharp\",\"math\"],[\"aws... | [
"Do a bitmask DP.",
"For each person, for each set of skills, we can update our understanding of a minimum set of people needed to perform this set of skills."
] | {
"canonical_parameter_names": [
"req_skills",
"people"
],
"leetcode_dataset_entry_point": "Solution().smallestSufficientTeam",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:11:05",
"... | typescript | {
"raw_signature": "function smallestSufficientTeam(req_skills: string[], people: string[][]): number[] {",
"container": null,
"callable": "smallestSufficientTeam",
"parameters": [
{
"name": "req_skills",
"type": "string[]"
},
{
"name": "people",
"type": "string[][]"
}
... |
1,128 | number-of-equivalent-domino-pairs | Easy | Given a list of dominoes, dominoes[i] = [a, b] is equivalent to dominoes[j] = [c, d] if and only if either (a == c and b == d), or (a == d and b == c) - that is, one domino can be rotated to be equal to another domino.
Return the number of pairs (i, j) for which 0 <= i < j < dominoes.length, and dominoes[i] is equival... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(dominoes = [[7, 8], [8, 7], [7, 8], [7, 8], [8, 7]]) == 10\n assert candidate(dominoes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 10\n assert candidate(dominoes = [[1, 2], [2, 1], [3, 4], [5, 6]]) == 1\n assert candidate(dom... | [
"[[1,2],[2,1],[3,4],[5,6]]",
"[[1,2],[1,2],[1,1],[1,2],[2,2]]"
] | [
"For each domino j, find the number of dominoes you've already seen (dominoes i with i < j) that are equivalent.",
"You can keep track of what you've seen using a hashmap."
] | {
"canonical_parameter_names": [
"dominoes"
],
"leetcode_dataset_entry_point": "Solution().numEquivDominoPairs",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:11:07",
"tests_total": 89,
... | typescript | {
"raw_signature": "function numEquivDominoPairs(dominoes: number[][]): number {",
"container": null,
"callable": "numEquivDominoPairs",
"parameters": [
{
"name": "dominoes",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source"... |
1,129 | shortest-path-with-alternating-colors | Medium | You are given an integer n, the number of nodes in a directed graph where the nodes are labeled from 0 to n - 1. Each edge is red or blue in this graph, and there could be self-edges and parallel edges.
You are given two arrays redEdges and blueEdges where:
- redEdges[i] = [a_i, b_i] indicates that there is a directe... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 4,redEdges = [[0, 1], [1, 2]],blueEdges = [[1, 3]]) == [0, 1, -1, 2]\n assert candidate(n = 4,redEdges = [[0, 1], [0, 2], [0, 3]],blueEdges = [[1, 2], [1, 3], [2, 3]]) == [0, 1, 1, 1]\n assert candidate(n = 2,redEdges = [[0, 0]... | [
"3\n[[0,1],[1,2]]\n[]",
"3\n[[0,1]]\n[[2,1]]"
] | [
"Do a breadth-first search, where the \"nodes\" are actually (Node, color of last edge taken)."
] | {
"canonical_parameter_names": [
"n",
"redEdges",
"blueEdges"
],
"leetcode_dataset_entry_point": "Solution().shortestAlternatingPaths",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20... | typescript | {
"raw_signature": "function shortestAlternatingPaths(n: number, redEdges: number[][], blueEdges: number[][]): number[] {",
"container": null,
"callable": "shortestAlternatingPaths",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "redEdges",
"type": "number[][]"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.