question_id int64 1 3.24k | task_id stringlengths 3 77 | difficulty stringclasses 3
values | problem_description stringlengths 193 3.69k | canonical_tests dict | public_tests listlengths 1 5 | hints listlengths 0 8 | metadata dict | language stringclasses 9
values | interface dict |
|---|---|---|---|---|---|---|---|---|---|
1,319 | number-of-operations-to-make-network-connected | Medium | There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [a_i, b_i] represents a connection between computers a_i and b_i. Any computer can reach any other computer directly or indirectly through the network.
You are given an initial computer netw... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(n = 5,connections = [[0, 1], [1, 2], [3, 4]]) == -1\n assert candidate(n = 6,connections = [[0, 1], [0, 2], [0, ... | [
"4\n[[0,1],[0,2],[1,2]]",
"6\n[[0,1],[0,2],[0,3],[1,2],[1,3]]",
"6\n[[0,1],[0,2],[0,3],[1,2]]"
] | [
"As long as there are at least (n - 1) connections, there is definitely a way to connect all computers.",
"Use DFS to determine the number of isolated computer clusters."
] | {
"canonical_parameter_names": [
"n",
"connections"
],
"leetcode_dataset_entry_point": "Solution().makeConnected",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:16:41",
"tests_total":... | typescript | {
"raw_signature": "function makeConnected(n: number, connections: number[][]): number {",
"container": null,
"callable": "makeConnected",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "connections",
"type": "number[][]"
}
],
"return_type": "number",
... |
1,320 | minimum-distance-to-type-a-word-using-two-fingers | Hard | You have a keyboard layout as shown above in the X-Y plane, where each English uppercase letter is located at some coordinate.
- For example, the letter 'A' is located at coordinate (0, 0), the letter 'B' is located at coordinate (0, 1), the letter 'P' is located at coordinate (2, 3) and the letter 'Z' is located at c... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word = \"QWERTYUIOPASDFGHJKLZXCVBNM\") == 52\n assert candidate(word = \"ZZZZZ\") == 0\n assert candidate(word = \"CAKE\") == 3\n assert candidate(word = \"RHYTHM\") == 9\n assert candidate(word = \"FINGER\") == 8\n assert... | [
"\"CAKE\"",
"\"HAPPY\""
] | [
"Use dynamic programming.",
"dp[i][j][k]: smallest movements when you have one finger on i-th char and the other one on j-th char already having written k first characters from word."
] | {
"canonical_parameter_names": [
"word"
],
"leetcode_dataset_entry_point": "Solution().minimumDistance",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:16:44",
"tests_total": 450,
"tests... | typescript | {
"raw_signature": "function minimumDistance(word: string): number {",
"container": null,
"callable": "minimumDistance",
"parameters": [
{
"name": "word",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
1,324 | print-words-vertically | Medium | Given a string s. Return all the words vertically in the same order in which they appear in s.
Words are returned as a list of strings, complete with spaces when is necessary. (Trailing spaces are not allowed).
Each word would be put on only one column and that in one column there will be only one word.
Example 1:
In... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"AB CD\") == ['AC', 'BD']\n assert candidate(s = \"A B C D\") == ['ABCD']\n assert candidate(s = \"A B C D E\") == ['ABCDE']\n assert candidate(s = \"SINGLEWORD\") == ['S', 'I', 'N', 'G', 'L', 'E', 'W', 'O', 'R', 'D']\n ... | [
"\"HOW ARE YOU\"",
"\"TO BE OR NOT TO BE\"",
"\"CONTEST IS COMING\""
] | [
"Use the maximum length of words to determine the length of the returned answer. However, don't forget to remove trailing spaces."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().printVertically",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:16:46",
"tests_total": 140,
"tests_dr... | typescript | {
"raw_signature": "function printVertically(s: string): string[] {",
"container": null,
"callable": "printVertically",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
1,326 | minimum-number-of-taps-to-open-to-water-a-garden | Hard | There is a one-dimensional garden on the x-axis. The garden starts at the point 0 and ends at the point n. (i.e., the length of the garden is n).
There are n + 1 taps located at points [0, 1, ..., n] in the garden.
Given an integer n and an integer array ranges of length n + 1 where ranges[i] (0-indexed) means the i-... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 10,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 5,ranges = [3, 4, 1, 1, 0, 0]) == 1\n assert candidate(n = 8,ranges = [4, 0, 0, 0, 0, 0, 0, 0, 4]) == 2\n assert candidate(n = 3,ranges = [0, 0, 0, ... | [
"5\n[3,4,1,1,0,0]",
"3\n[0,0,0,0]"
] | [
"Create intervals of the area covered by each tap, sort intervals by the left end.",
"We need to cover the interval [0, n]. we can start with the first interval and out of all intervals that intersect with it we choose the one that covers the farthest point to the right.",
"What if there is a gap between interv... | {
"canonical_parameter_names": [
"n",
"ranges"
],
"leetcode_dataset_entry_point": "Solution().minTaps",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:16:50",
"tests_total": 93,
"tes... | typescript | {
"raw_signature": "function minTaps(n: number, ranges: number[]): number {",
"container": null,
"callable": "minTaps",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "ranges",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetc... |
1,328 | break-a-palindrome | Medium | Given a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the resulting string is not a palindrome and that it is the lexicographically smallest one possible.
Return the resulting string. If there is no way to replace a character to make... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(palindrome = \"refer\") == \"aefer\"\n assert candidate(palindrome = \"abba\") == \"aaba\"\n assert candidate(palindrome = \"rotor\") == \"aotor\"\n assert candidate(palindrome = \"aa\") == \"ab\"\n assert candidate(palindrom... | [
"\"abccba\"",
"\"a\""
] | [
"How to detect if there is impossible to perform the replacement? Only when the length = 1.",
"Change the first non 'a' character to 'a'.",
"What if the string has only 'a'?",
"Change the last character to 'b'."
] | {
"canonical_parameter_names": [
"palindrome"
],
"leetcode_dataset_entry_point": "Solution().breakPalindrome",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:16:52",
"tests_total": 118,
... | typescript | {
"raw_signature": "function breakPalindrome(palindrome: string): string {",
"container": null,
"callable": "breakPalindrome",
"parameters": [
{
"name": "palindrome",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
1,329 | sort-the-matrix-diagonally | Medium | A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix's end. For example, the matrix diagonal starting from mat[2][0], where mat is a 6 x 3 matrix, includes cells mat[2][0], mat[3][1], and mat[... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(mat = [[1]]) == [[1]]\n assert candidate(mat = [[37, 47, 1, 44], [20, 3, 2, 90], [96, 50, 4, 24]]) == [[3, 2, 1, 44], [20, 4, 24, 90], [96, 50, 37, 47]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, ... | [
"[[3,3,1,1],[2,2,1,2],[1,1,1,2]]",
"[[11,25,66,1,69,7],[23,55,17,45,15,52],[75,31,36,44,58,8],[22,27,33,25,68,4],[84,28,14,11,5,50]]"
] | [
"Use a data structure to store all values of each diagonal.",
"How to index the data structure with the id of the diagonal?",
"All cells in the same diagonal (i,j) have the same difference so we can get the diagonal of a cell using the difference i-j."
] | {
"canonical_parameter_names": [
"mat"
],
"leetcode_dataset_entry_point": "Solution().diagonalSort",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:16:55",
"tests_total": 81,
"tests_drop... | typescript | {
"raw_signature": "function diagonalSort(mat: number[][]): number[][] {",
"container": null,
"callable": "diagonalSort",
"parameters": [
{
"name": "mat",
"type": "number[][]"
}
],
"return_type": "number[][]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
1,330 | reverse-subarray-to-maximize-array-value | Hard | You are given an integer array nums. The value of this array is defined as the sum of |nums[i] - nums[i + 1]| for all 0 <= i < nums.length - 1.
You are allowed to select any subarray of the given array and reverse it. You can perform this operation only once.
Find maximum possible value of the final array.
Example 1... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 5]) == 9\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 230\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == 22\n assert candidate(nums = [1, -1, 1, -1, 1]) == 8\n assert candid... | [
"[2,3,1,5,4]",
"[2,4,9,24,2,1,10]"
] | [
"What's the score after reversing a sub-array [L, R] ?",
"It's the score without reversing it + abs(a[R] - a[L-1]) + abs(a[L] - a[R+1]) - abs(a[L] - a[L-1]) - abs(a[R] - a[R+1])",
"How to maximize that formula given that abs(x - y) = max(x - y, y - x) ?",
"This can be written as max(max(a[R] - a[L - 1], a[L -... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maxValueAfterReverse",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:16:57",
"tests_total": 99,
"t... | typescript | {
"raw_signature": "function maxValueAfterReverse(nums: number[]): number {",
"container": null,
"callable": "maxValueAfterReverse",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcod... |
1,331 | rank-transform-of-an-array | Easy | Given an array of integers arr, replace each element with its rank.
The rank represents how large the element is. The rank has the following rules:
- Rank is an integer starting from 1.
- The larger the element, the larger the rank. If two elements are equal, their rank must be the same.
- Rank should be as small as ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [5, 4, 3, 2, 1]) == [5, 4, 3, 2, 1]\n assert candidate(arr = [-10, 100, 0, 5, 3]) == [1, 5, 2, 4, 3]\n assert candidate(arr = [-10, -20, -30, -40, -50]) == [5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 3, 4, 5]) == [1, 2... | [
"[40,10,20,30]",
"[100,100,100]",
"[37,12,28,9,100,56,80,5,12]"
] | [
"Use a temporary array to copy the array and sort it.",
"The rank of each element is the number of unique elements smaller than it in the sorted array plus one."
] | {
"canonical_parameter_names": [
"arr"
],
"leetcode_dataset_entry_point": "Solution().arrayRankTransform",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:16:59",
"tests_total": 113,
"tes... | typescript | {
"raw_signature": "function arrayRankTransform(arr: number[]): number[] {",
"container": null,
"callable": "arrayRankTransform",
"parameters": [
{
"name": "arr",
"type": "number[]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
1,332 | remove-palindromic-subsequences | Easy | You are given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s.
Return the minimum number of steps to make the given string empty.
A string is a subsequence of a given string if it is generated by deleting some characters of a given string without c... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"b\") == 1\n assert candidate(s = \"aabbab\") == 2\n assert candidate(s = \"baba\") == 2\n assert candidate(s = \"aababb\") == 2\n assert candidate(s = \"abbaab\") == 2\n assert candidate(s = \"ab\") == 2\n assert ... | [
"\"ababa\"",
"\"abb\"",
"\"baabb\""
] | [
"Use the fact that string contains only 2 characters.",
"Are subsequences composed of only one type of letter always palindrome strings ?"
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().removePalindromeSub",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:02",
"tests_total": 172,
"test... | typescript | {
"raw_signature": "function removePalindromeSub(s: string): number {",
"container": null,
"callable": "removePalindromeSub",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
1,333 | filter-restaurants-by-vegan-friendly-price-and-distance | Medium | Given the array restaurants where restaurants[i] = [id_i, rating_i, veganFriendly_i, price_i, distance_i]. You have to filter the restaurants using three filters.
The veganFriendly filter will be either true (meaning you should only include restaurants with veganFriendly_i set to true) or false (meaning you can includ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(restaurants = [[1, 4, 1, 40, 10], [2, 8, 0, 50, 5], [3, 8, 1, 30, 4], [4, 10, 0, 10, 3], [5, 1, 1, 15, 1]],veganFriendly = 0,maxPrice = 50,maxDistance = 10) == [4, 3, 2, 1, 5]\n assert candidate(restaurants = [[1, 4, 1, 40, 10], [2, 8... | [
"[[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]]\n1\n50\n10",
"[[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]]\n0\n50\n10",
"[[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]]\n0\n30\n3"
] | [
"Do the filtering and sort as said. Note that the id may not be the index in the array."
] | {
"canonical_parameter_names": [
"restaurants",
"veganFriendly",
"maxPrice",
"maxDistance"
],
"leetcode_dataset_entry_point": "Solution().filterRestaurants",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"f... | typescript | {
"raw_signature": "function filterRestaurants(restaurants: number[][], veganFriendly: number, maxPrice: number, maxDistance: number): number[] {",
"container": null,
"callable": "filterRestaurants",
"parameters": [
{
"name": "restaurants",
"type": "number[][]"
},
{
"name": "veganF... |
1,334 | find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance | Medium | There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [from_i, to_i, weight_i] represents a bidirectional and weighted edge between cities from_i and to_i, and given the integer distanceThreshold.
Return the city with the smallest number of cities that are reachable through some path and wh... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 5,edges = [[0, 1, 2], [0, 4, 8], [1, 2, 3], [1, 4, 2], [2, 3, 1], [3, 4, 1]],distanceThreshold = 2) == 0\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 1], [1, 3, 4], [2, 3, 1]],distanceThreshold = 4) == 3\n assert candida... | [
"4\n[[0,1,3],[1,2,1],[1,3,4],[2,3,1]]\n4",
"5\n[[0,1,2],[0,4,8],[1,2,3],[1,4,2],[2,3,1],[3,4,1]]\n2"
] | [
"Use Floyd-Warshall's algorithm to compute any-point to any-point distances. (Or can also do Dijkstra from every node due to the weights are non-negative).",
"For each city calculate the number of reachable cities within the threshold, then search for the optimal city."
] | {
"canonical_parameter_names": [
"n",
"edges",
"distanceThreshold"
],
"leetcode_dataset_entry_point": "Solution().findTheCity",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:06",... | typescript | {
"raw_signature": "function findTheCity(n: number, edges: number[][], distanceThreshold: number): number {",
"container": null,
"callable": "findTheCity",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "edges",
"type": "number[][]"
},
{
"name": "d... |
1,335 | minimum-difficulty-of-a-job-schedule | Hard | You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the i^th job, you have to finish all the jobs j where 0 <= j < i).
You have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maxi... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 10) == 55\n assert candidate(jobDifficulty = [300, 500, 1000],d = 3) == 1800\n assert candidate(jobDifficulty = [6, 5, 4, 3, 2, 1],d = 2) == 7\n assert candidate(jobDifficulty ... | [
"[6,5,4,3,2,1]\n2",
"[9,9,9]\n4",
"[1,1,1]\n3"
] | [
"Use DP. Try to cut the array into d non-empty sub-arrays. Try all possible cuts for the array.",
"Use dp[i][j] where DP states are i the index of the last cut and j the number of remaining cuts. Complexity is O(n * n * d)."
] | {
"canonical_parameter_names": [
"jobDifficulty",
"d"
],
"leetcode_dataset_entry_point": "Solution().minDifficulty",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:08",
"tests_total... | typescript | {
"raw_signature": "function minDifficulty(jobDifficulty: number[], d: number): number {",
"container": null,
"callable": "minDifficulty",
"parameters": [
{
"name": "jobDifficulty",
"type": "number[]"
},
{
"name": "d",
"type": "number"
}
],
"return_type": "number",
... |
1,337 | the-k-weakest-rows-in-a-matrix | Easy | You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the civilians. That is, all the 1's will appear to the left of all the 0's in each row.
A row i is weaker than a row j if one of the following is true:
- The number of sold... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 2) == [0, 1]\n assert candidate(mat = [[0, 0, 0, 0], [1, 0, 0, 0], [1, 1, 0, 0], [1, 1, 1, 0]],k = 2) == [0, 1]\n assert candidate(mat = [[1, 1, 1, 1], ... | [
"[[1,1,0,0,0],[1,1,1,1,0],[1,0,0,0,0],[1,1,0,0,0],[1,1,1,1,1]]\n3",
"[[1,0,0,0],[1,1,1,1],[1,0,0,0],[1,0,0,0]]\n2"
] | [
"Sort the matrix row indexes by the number of soldiers and then row indexes."
] | {
"canonical_parameter_names": [
"mat",
"k"
],
"leetcode_dataset_entry_point": "Solution().kWeakestRows",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:11",
"tests_total": 80,
"t... | typescript | {
"raw_signature": "function kWeakestRows(mat: number[][], k: number): number[] {",
"container": null,
"callable": "kWeakestRows",
"parameters": [
{
"name": "mat",
"type": "number[][]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number[]",
"signature_sou... |
1,338 | reduce-array-size-to-the-half | Medium | You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array.
Return the minimum size of the set so that at least half of the integers of the array are removed.
Example 1:
Input: arr = [3,3,3,3,5,5,5,2,2,7]
Output: 2
Explanation: Choosing {3,7} wi... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [7, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == ... | [
"[3,3,3,3,5,5,5,2,2,7]",
"[7,7,7,7,7,7]"
] | [
"Count the frequency of each integer in the array.",
"Start with an empty set, add to the set the integer with the maximum frequency.",
"Keep Adding the integer with the max frequency until you remove at least half of the integers."
] | {
"canonical_parameter_names": [
"arr"
],
"leetcode_dataset_entry_point": "Solution().minSetSize",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:13",
"tests_total": 85,
"tests_droppe... | typescript | {
"raw_signature": "function minSetSize(arr: number[]): number {",
"container": null,
"callable": "minSetSize",
"parameters": [
{
"name": "arr",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,340 | jump-game-v | Hard | Given an array of integers arr and an integer d. In one step you can jump from index i to index:
- i + x where: i + x < arr.length and 0 < x <= d.
- i - x where: i - x >= 0 and 0 < x <= d.
In addition, you can only jump from index i to index j if arr[i] > arr[j] and arr[i] > arr[k] for all indices k between i and j... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5],d = 4) == 5\n assert candidate(arr = [1, 2, 3, 4, 5],d = 2) == 5\n assert candidate(arr = [3, 3, 3, 3, 3],d = 3) == 1\n assert candid... | [
"[6,4,14,6,8,13,9,7,10,6,12]\n2",
"[3,3,3,3,3]\n3",
"[7,6,5,4,3,2,1]\n1"
] | [
"Use dynamic programming. dp[i] is max jumps you can do starting from index i. Answer is max(dp[i]).",
"dp[i] = 1 + max (dp[j]) where j is all indices you can reach from i."
] | {
"canonical_parameter_names": [
"arr",
"d"
],
"leetcode_dataset_entry_point": "Solution().maxJumps",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:18",
"tests_total": 122,
"test... | typescript | {
"raw_signature": "function maxJumps(arr: number[], d: number): number {",
"container": null,
"callable": "maxJumps",
"parameters": [
{
"name": "arr",
"type": "number[]"
},
{
"name": "d",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/... |
1,342 | number-of-steps-to-reduce-a-number-to-zero | Easy | Given an integer num, return the number of steps to reduce it to zero.
In one step, if the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it.
Example 1:
Input: num = 14
Output: 6
Explanation:
Step 1) 14 is even; divide by 2 and obtain 7.
Step 2) 7 is odd; subtract 1 and ob... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = 14) == 6\n assert candidate(num = 1000000) == 26\n assert candidate(num = 8) == 4\n assert candidate(num = 65535) == 31\n assert candidate(num = 0) == 0\n assert candidate(num = 2) == 2\n assert candidate(num = 1)... | [
"14",
"8",
"123"
] | [
"Simulate the process to get the final answer."
] | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().numberOfSteps",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:20",
"tests_total": 59,
"tests_dro... | typescript | {
"raw_signature": "function numberOfSteps(num: number): number {",
"container": null,
"callable": "numberOfSteps",
"parameters": [
{
"name": "num",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,343 | number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold | Medium | Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.
Example 1:
Input: arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4
Output: 3
Explanation: Sub-arrays [2,5,5],[5,5,5] and [5,5,8] have averages 4, 5 and 6 respectively... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [2, 2, 2, 2, 5, 5, 5, 8],k = 3,threshold = 4) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5],k = 3,threshold = 5) == 5\n assert candidate(arr = [10000, 10000, 10000],k = 3,threshold = 10000) == 1\n assert candidate(ar... | [
"[2,2,2,2,5,5,5,8]\n3\n4",
"[11,13,17,23,29,31,7,5,2,3]\n3\n5"
] | [
"Start with a window of size K and test its average against the threshold.",
"Keep moving the window by one element maintaining its size k until you cover the whole array. Count the number of windows that have an average greater than or equal to the threshold."
] | {
"canonical_parameter_names": [
"arr",
"k",
"threshold"
],
"leetcode_dataset_entry_point": "Solution().numOfSubarrays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:22",
"tes... | typescript | {
"raw_signature": "function numOfSubarrays(arr: number[], k: number, threshold: number): number {",
"container": null,
"callable": "numOfSubarrays",
"parameters": [
{
"name": "arr",
"type": "number[]"
},
{
"name": "k",
"type": "number"
},
{
"name": "threshold",... |
1,344 | angle-between-hands-of-a-clock | Medium | Given two numbers, hour and minutes, return the smaller angle (in degrees) formed between the hour and the minute hand.
Answers within 10^-5 of the actual value will be accepted as correct.
Example 1:
Input: hour = 12, minutes = 30
Output: 165
Example 2:
Input: hour = 3, minutes = 30
Output: 75
Example 3:
Input:... | {
"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... | [
"12\n30",
"3\n30",
"3\n15"
] | [
"The tricky part is determining how the minute hand affects the position of the hour hand.",
"Calculate the angles separately then find the difference."
] | {
"canonical_parameter_names": [
"hour",
"minutes"
],
"leetcode_dataset_entry_point": "Solution().angleClock",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:24",
"tests_total": 72,... | typescript | {
"raw_signature": "function angleClock(hour: number, minutes: number): number {",
"container": null,
"callable": "angleClock",
"parameters": [
{
"name": "hour",
"type": "number"
},
{
"name": "minutes",
"type": "number"
}
],
"return_type": "number",
"signature_sourc... |
1,345 | jump-game-iv | Hard | Given an array of integers arr, you are initially positioned at the first index of the array.
In one step you can jump from index i to index:
- i + 1 where: i + 1 < arr.length.
- i - 1 where: i - 1 >= 0.
- j where: arr[i] == arr[j] and i != j.
Return the minimum number of steps to reach the last index of the array.
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [11, 22, 7, 7, 7, 7, 7, 7, 7, 22, 13]) == 3\n assert candidate(arr = [6, 1, 9, 6, 9, 1, 9, 6, 1, 9]) == 3\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 11, 11, 11, 11, 11, 11]) == 3\n assert candidate(arr = [7, 6, 9, 6, 9, 6... | [
"[100,-23,-23,404,100,23,23,23,3,404]",
"[7]",
"[7,6,9,6,9,6,9,7]"
] | [
"Build a graph of n nodes where nodes are the indices of the array and edges for node i are nodes i+1, i-1, j where arr[i] == arr[j].",
"Start bfs from node 0 and keep distance. The answer is the distance when you reach node n-1."
] | {
"canonical_parameter_names": [
"arr"
],
"leetcode_dataset_entry_point": "Solution().minJumps",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:27",
"tests_total": 60,
"tests_dropped"... | typescript | {
"raw_signature": "function minJumps(arr: number[]): number {",
"container": null,
"callable": "minJumps",
"parameters": [
{
"name": "arr",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,346 | check-if-n-and-its-double-exist | Easy | Given an array arr of integers, check if there exist two indices i and j such that :
- i != j
- 0 <= i, j < arr.length
- arr[i] == 2 * arr[j]
Example 1:
Input: arr = [10,2,5,3]
Output: true
Explanation: For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j]
Example 2:
Input: arr = [3,1,7,11]
Output: false
Explan... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [2, 4, 6, 8, 10]) == True\n assert candidate(arr = [6, 10, 1, 0, -3, 3]) == True\n assert candidate(arr = [-3, -6, -1, 0, 1, 2, 3]) == True\n assert candidate(arr = [-2, -4, -6, -8, -10]) == True\n assert candidate(arr ... | [
"[10,2,5,3]",
"[3,1,7,11]"
] | [
"Loop from i = 0 to arr.length, maintaining in a hashTable the array elements from [0, i - 1].",
"On each step of the loop check if we have seen the element 2 * arr[i] so far.",
"Also check if we have seen arr[i] / 2 in case arr[i] % 2 == 0."
] | {
"canonical_parameter_names": [
"arr"
],
"leetcode_dataset_entry_point": "Solution().checkIfExist",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:29",
"tests_total": 147,
"tests_dro... | typescript | {
"raw_signature": "function checkIfExist(arr: number[]): boolean {",
"container": null,
"callable": "checkIfExist",
"parameters": [
{
"name": "arr",
"type": "number[]"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
1,347 | minimum-number-of-steps-to-make-two-strings-anagram | Medium | You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character.
Return the minimum number of steps to make t an anagram of s.
An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.
Exampl... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abacabadabacaba\",t = \"abcadbabacabaab\") == 1\n assert candidate(s = \"transform\",t = \"formartin\") == 1\n assert candidate(s = \"aabbcc\",t = \"ccbbaa\") == 0\n assert candidate(s = \"minimum\",t = \"numinum\") == 2\n... | [
"\"bab\"\n\"aba\"",
"\"leetcode\"\n\"practice\"",
"\"anagram\"\n\"mangaar\""
] | [
"Count the frequency of characters of each string.",
"Loop over all characters if the frequency of a character in t is less than the frequency of the same character in s then add the difference between the frequencies to the answer."
] | {
"canonical_parameter_names": [
"s",
"t"
],
"leetcode_dataset_entry_point": "Solution().minSteps",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:31",
"tests_total": 113,
"tests_... | typescript | {
"raw_signature": "function minSteps(s: string, t: string): number {",
"container": null,
"callable": "minSteps",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "t",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnip... |
1,349 | maximum-students-taking-exam | Hard | Given a m * n matrix seats that represent seats distributions in a classroom. If a seat is broken, it is denoted by '#' character otherwise it is denoted by a '.' character.
Students can see the answers of those sitting next to the left, right, upper left and upper right, but he cannot see the answers of the student s... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['#', '.', '#', '#', '.', '#'], ['.', '#', '#', '#', '#... | [
"[[\"#\",\".\",\"#\",\"#\",\".\",\"#\"],[\".\",\"#\",\"#\",\"#\",\"#\",\".\"],[\"#\",\".\",\"#\",\"#\",\".\",\"#\"]]",
"[[\".\",\"#\"],[\"#\",\"#\"],[\"#\",\".\"],[\"#\",\"#\"],[\".\",\"#\"]]",
"[[\"#\",\".\",\".\",\".\",\"#\"],[\".\",\"#\",\".\",\"#\",\".\"],[\".\",\".\",\"#\",\".\",\".\"],[\".\",\"#\",\".\",\... | [
"Students in row i only can see exams in row i+1.",
"Use Dynamic programming to compute the result given a (current row, bitmask people seated in previous row)."
] | {
"canonical_parameter_names": [
"seats"
],
"leetcode_dataset_entry_point": "Solution().maxStudents",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:33",
"tests_total": 66,
"tests_dro... | typescript | {
"raw_signature": "function maxStudents(seats: string[][]): number {",
"container": null,
"callable": "maxStudents",
"parameters": [
{
"name": "seats",
"type": "string[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
1,351 | count-negative-numbers-in-a-sorted-matrix | Easy | Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.
Example 1:
Input: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]
Output: 8
Explanation: There are 8 negatives number in the matrix.
Example 2:
Input: grid = [[3,2... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[-1, -1], [-1, -1]]) == 4\n assert candidate(grid = [[-3], [-2], [-1], [0], [1]]) == 0\n assert candidate(grid = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == 12\n assert candidate(grid = [[-1, -1, -1], [-5,... | [
"[[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]",
"[[3,2],[1,0]]"
] | [
"Use binary search for optimization or simply brute force."
] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().countNegatives",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:36",
"tests_total": 96,
"tests_d... | typescript | {
"raw_signature": "function countNegatives(grid: number[][]): number {",
"container": null,
"callable": "countNegatives",
"parameters": [
{
"name": "grid",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
1,353 | maximum-number-of-events-that-can-be-attended | Medium | You are given an array of events where events[i] = [startDay_i, endDay_i]. Every event i starts at startDay_iand ends at endDay_i.
You can attend an event i at any day d where startDay_i <= d <= endDay_i. You can only attend one event at any time d.
Return the maximum number of events you can attend.
Example 1:
Inp... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(events = [[1, 100], [1, 100], [1, 100], [1, 100], [1, 100]]) == 5\n assert candidate(events = [[1, 3], [2, 4], [3, 5], [4, 6]]) == 4\n assert candidate(events = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55]]) == 5\n assert c... | [
"[[1,2],[2,3],[3,4]]",
"[[1,2],[2,3],[3,4],[1,2]]"
] | [
"Sort the events by the start time and in case of tie by the end time in ascending order.",
"Loop over the sorted events. Attend as much as you can and keep the last day occupied. When you try to attend new event keep in mind the first day you can attend a new event in."
] | {
"canonical_parameter_names": [
"events"
],
"leetcode_dataset_entry_point": "Solution().maxEvents",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:38",
"tests_total": 98,
"tests_drop... | typescript | {
"raw_signature": "function maxEvents(events: number[][]): number {",
"container": null,
"callable": "maxEvents",
"parameters": [
{
"name": "events",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
1,354 | construct-target-array-with-multiple-sums | Hard | You are given an array target of n integers. From a starting array arr consisting of n 1's, you may perform the following procedure :
- let x be the sum of all elements currently in your array.
- choose index i, such that 0 <= i < n and set the value of arr at index i to x.
- You may repeat this procedure as many time... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(target = [1, 2, 3, 4, 5]) == False\n assert candidate(target = [1000000000, 1, 1]) == False\n assert candidate(target = [5, 7, 1]) == True\n assert candida... | [
"[9,3,5]",
"[1,1,1,2]",
"[8,5]"
] | [
"Given that the sum is strictly increasing, the largest element in the target must be formed in the last step by adding the total sum in the previous step. Thus, we can simulate the process in a reversed way.",
"Subtract the largest with the rest of the array, and put the new element into the array. Repeat until ... | {
"canonical_parameter_names": [
"target"
],
"leetcode_dataset_entry_point": "Solution().isPossible",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:40",
"tests_total": 99,
"tests_dro... | typescript | {
"raw_signature": "function isPossible(target: number[]): boolean {",
"container": null,
"callable": "isPossible",
"parameters": [
{
"name": "target",
"type": "number[]"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
1,356 | sort-integers-by-the-number-of-1-bits | Easy | You are given an integer array arr. Sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order.
Return the array after sorting it.
Example 1:
Input: arr = [0,1,2,3,4,5,6... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [3, 7, 8, 9]) == [8, 3, 9, 7]\n assert candidate(arr = [1, 3, 5, 7, 9]) == [1, 3, 5, 9, 7]\n assert candidate(arr = [1, 0, 2, 3, 4]) == [0, 1, 2, 4, 3]\n assert candidate(arr = [3, 8, 3, 6, 5, 7, 9, 2]) == [2, 8, 3, 3, 5, ... | [
"[0,1,2,3,4,5,6,7,8]",
"[1024,512,256,128,64,32,16,8,4,2,1]"
] | [
"Simulate the problem. Count the number of 1's in the binary representation of each integer.",
"Sort by the number of 1's ascending and by the value in case of tie."
] | {
"canonical_parameter_names": [
"arr"
],
"leetcode_dataset_entry_point": "Solution().sortByBits",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:42",
"tests_total": 96,
"tests_droppe... | typescript | {
"raw_signature": "function sortByBits(arr: number[]): number[] {",
"container": null,
"callable": "sortByBits",
"parameters": [
{
"name": "arr",
"type": "number[]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,358 | number-of-substrings-containing-all-three-characters | Medium | Given a string s consisting only of characters a, b and c.
Return the number of substrings containing at least one occurrence of all these characters a, b and c.
Example 1:
Input: s = "abcabc"
Output: 10
Explanation: The substrings containing at least one occurrence of the characters a, b and c are "abc", "abca", "a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"aaabbbccc\") == 9\n assert candidate(s = \"abcba\") == 5\n assert candidate(s = \"cba\") == 1\n assert candidate(s = \"cbaacb\") == 8\n assert candidate(s = \"bbbacbac\") == 18\n assert candidate(s = \"ccccabc\") == ... | [
"\"abcabc\"",
"\"aaacb\"",
"\"abc\""
] | [
"For each position we simply need to find the first occurrence of a/b/c on or after this position.",
"So we can pre-compute three link-list of indices of each a, b, and c."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().numberOfSubstrings",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:44",
"tests_total": 130,
"tests... | typescript | {
"raw_signature": "function numberOfSubstrings(s: string): number {",
"container": null,
"callable": "numberOfSubstrings",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
1,359 | count-all-valid-pickup-and-delivery-options | Hard | Given n orders, each order consists of a pickup and a delivery service.
Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i).
Since the answer may be too large, return it modulo 10^9 + 7.
Example 1:
Input: n = 1
Output: 1
Explanation: Unique order (P1, D1), Delivery ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 3) == 90\n assert candidate(n = 250) == 418733499\n assert candidate(n = 100) == 14159051\n assert candidate(n = 4) == 2520\n assert candidate(n = 2) == 6\n assert candidate(n = 20) == 580270580\n assert candidate(n... | [
"1",
"2",
"3"
] | [
"Use the permutation and combination theory to add one (P, D) pair each time until n pairs."
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().countOrders",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:47",
"tests_total": 32,
"tests_dropped... | typescript | {
"raw_signature": "function countOrders(n: number): number {",
"container": null,
"callable": "countOrders",
"parameters": [
{
"name": "n",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,360 | number-of-days-between-two-dates | Easy | Write a program to count the number of days between two dates.
The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples.
Example 1:
Input: date1 = "2019-06-29", date2 = "2019-06-30"
Output: 1
Example 2:
Input: date1 = "2020-01-15", date2 = "2019-12-31"
Output: 15
Constraints:
- The... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(date1 = \"2019-02-28\",date2 = \"2019-03-01\") == 1\n assert candidate(date1 = \"2020-01-15\",date2 = \"2019-12-31\") == 15\n assert candidate(date1 = \"2000-03-01\",date2 = \"2000-02-29\") == 1\n assert candidate(date1 = \"2023... | [
"\"2019-06-29\"\n\"2019-06-30\"",
"\"2020-01-15\"\n\"2019-12-31\""
] | [
"Create a function f(date) that counts the number of days from 1900-01-01 to date. How can we calculate the answer ?",
"The answer is just |f(date1) - f(date2)|.",
"How to construct f(date) ?",
"For each year from 1900 to year - 1 sum up 365 or 366 in case of leap years. Then sum up for each month the number ... | {
"canonical_parameter_names": [
"date1",
"date2"
],
"leetcode_dataset_entry_point": "Solution().daysBetweenDates",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:49",
"tests_total"... | typescript | {
"raw_signature": "function daysBetweenDates(date1: string, date2: string): number {",
"container": null,
"callable": "daysBetweenDates",
"parameters": [
{
"name": "date1",
"type": "string"
},
{
"name": "date2",
"type": "string"
}
],
"return_type": "number",
"signa... |
1,361 | validate-binary-tree-nodes | Medium | You have n binary tree nodes numbered from 0 to n - 1 where node i has two children leftChild[i] and rightChild[i], return true if and only if all the given nodes form exactly one valid binary tree.
If node i has no left child then leftChild[i] will equal -1, similarly for the right child.
Note that the nodes have no... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 2,leftChild = [1, 0],rightChild = [-1, -1]) == False\n assert candidate(n = 3,leftChild = [1, -1, -1],rightChild = [2, -1, -1]) == True\n assert candidate(n = 3,leftChild = [1, 0, -1],rightChild = [-1, -1, -1]) == False\n as... | [
"4\n[1,-1,3,-1]\n[2,-1,-1,-1]",
"4\n[1,-1,3,-1]\n[2,3,-1,-1]",
"2\n[1,0]\n[-1,-1]"
] | [
"Find the parent of each node.",
"A valid tree must have nodes with only one parent and exactly one node with no parent."
] | {
"canonical_parameter_names": [
"n",
"leftChild",
"rightChild"
],
"leetcode_dataset_entry_point": "Solution().validateBinaryTreeNodes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T2... | typescript | {
"raw_signature": "function validateBinaryTreeNodes(n: number, leftChild: number[], rightChild: number[]): boolean {",
"container": null,
"callable": "validateBinaryTreeNodes",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "leftChild",
"type": "number[]"
}... |
1,362 | closest-divisors | Medium | Given an integer num, find the closest two integers in absolute difference whose product equals num + 1 or num + 2.
Return the two integers in any order.
Example 1:
Input: num = 8
Output: [3,3]
Explanation: For num + 1 = 9, the closest divisors are 3 & 3, for num + 2 = 10, the closest divisors are 2 & 5, hence 3 & 3... | {
"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 ... | [
"8",
"123",
"999"
] | [
"Find the divisors of n+1 and n+2.",
"To find the divisors of a number, you only need to iterate to the square root of that number."
] | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().closestDivisors",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:53",
"tests_total": 53,
"tests_d... | typescript | {
"raw_signature": "function closestDivisors(num: number): number[] {",
"container": null,
"callable": "closestDivisors",
"parameters": [
{
"name": "num",
"type": "number"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
1,363 | largest-multiple-of-three | Hard | Given an array of digits digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order. If there is no answer return an empty string.
Since the answer may not fit in an integer data type, return the answer as a string. Note that the returning answer must not con... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(digits = [5, 5, 5]) == \"555\"\n assert candidate(digits = [3, 3, 3]) == \"333\"\n assert candidate(digits = [3, 3, 3, 3, 3]) == \"33333\"\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert... | [
"[8,1,9]",
"[8,6,7,1,0]",
"[1]"
] | [
"A number is a multiple of three if and only if its sum of digits is a multiple of three.",
"Use dynamic programming.",
"To find the maximum number, try to maximize the number of digits of the number.",
"Sort the digits in descending order to find the maximum number."
] | {
"canonical_parameter_names": [
"digits"
],
"leetcode_dataset_entry_point": "Solution().largestMultipleOfThree",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:56",
"tests_total": 72,
... | typescript | {
"raw_signature": "function largestMultipleOfThree(digits: number[]): string {",
"container": null,
"callable": "largestMultipleOfThree",
"parameters": [
{
"name": "digits",
"type": "number[]"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": ... |
1,365 | how-many-numbers-are-smaller-than-the-current-number | Easy | Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of valid j's such that j != i and nums[j] < nums[i].
Return the answer in an array.
Example 1:
Input: nums = [8,1,2,2,3]
Output: [4,0,1,1,3]
Explanation:
For nums[... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [8, 1, 2, 2, 3]) == [4, 0, 1, 1, 3]\n assert cand... | [
"[8,1,2,2,3]",
"[6,5,4,8]",
"[7,7,7,7]"
] | [
"Brute force for each array element.",
"In order to improve the time complexity, we can sort the array and get the answer for each array element."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().smallerNumbersThanCurrent",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:17:58",
"tests_total": 110... | typescript | {
"raw_signature": "function smallerNumbersThanCurrent(nums: number[]): number[] {",
"container": null,
"callable": "smallerNumbersThanCurrent",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_sou... |
1,366 | rank-teams-by-votes | Medium | In a special ranking system, each voter gives a rank from highest to lowest to all teams participating in the competition.
The ordering of teams is decided by who received the most position-one votes. If two or more teams tie in the first position, we consider the second position to resolve the conflict, if they tie a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(votes = ['ABC', 'ACB', 'ABC', 'ACB', 'ACB']) == \"ACB\"\n assert candidate(votes = ['WXYZ', 'XYZW']) == \"XWYZ\"\n assert candidate(votes = ['BCA', 'CAB', 'ACB', 'BAC', 'CBA', 'ABC']) == \"ABC\"\n assert candidate(votes = ['A', ... | [
"[\"ABC\",\"ACB\",\"ABC\",\"ACB\",\"ACB\"]",
"[\"WXYZ\",\"XYZW\"]",
"[\"ZMNAGUEDSJYLBOPHRQICWFXTVK\"]"
] | [
"Build array rank where rank[i][j] is the number of votes for team i to be the j-th rank.",
"Sort the teams by rank array. if rank array is the same for two or more teams, sort them by the ID in ascending order."
] | {
"canonical_parameter_names": [
"votes"
],
"leetcode_dataset_entry_point": "Solution().rankTeams",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:00",
"tests_total": 73,
"tests_dropp... | typescript | {
"raw_signature": "function rankTeams(votes: string[]): string {",
"container": null,
"callable": "rankTeams",
"parameters": [
{
"name": "votes",
"type": "string[]"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,368 | minimum-cost-to-make-at-least-one-valid-path-in-a-grid | Hard | Given an m x n grid. Each cell of the grid has a sign pointing to the next cell you should visit if you are currently in this cell. The sign of grid[i][j] can be:
- 1 which means go to the cell to the right. (i.e go from grid[i][j] to grid[i][j + 1])
- 2 which means go to the cell to the left. (i.e go from grid[i][j] ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 2\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]]) == 3\n assert candidate(grid = [[4, 4, 4], [4, 4, 4], [4, 4, 4]]) == 4\n assert candidate(grid = ... | [
"[[1,1,1,1],[2,2,2,2],[1,1,1,1],[2,2,2,2]]",
"[[1,1,3],[3,2,2],[1,1,4]]",
"[[1,2],[4,3]]"
] | [
"Build a graph where grid[i][j] is connected to all the four side-adjacent cells with weighted edge. the weight is 0 if the sign is pointing to the adjacent cell or 1 otherwise.",
"Do BFS from (0, 0) visit all edges with weight = 0 first. the answer is the distance to (m -1, n - 1)."
] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().minCost",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:04",
"tests_total": 87,
"tests_dropped"... | typescript | {
"raw_signature": "function minCost(grid: number[][]): number {",
"container": null,
"callable": "minCost",
"parameters": [
{
"name": "grid",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,370 | increasing-decreasing-string | Easy | You are given a string s. Reorder the string using the following algorithm:
1. Remove the smallest character from s and append it to the result.
2. Remove the smallest character from s that is greater than the last appended character, and append it to the result.
3. Repeat step 2 until no more characters can be remove... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"rqy\") == \"qry\"\n assert candidate(s = \"fuvofn\") == \"fnouvf\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"vibhu\") == \"bhiuv\"\n assert candida... | [
"\"aaaabbbbcccc\"",
"\"rat\""
] | [
"Count the frequency of each character.",
"Loop over all character from 'a' to 'z' and append the character if it exists and decrease frequency by 1. Do the same from 'z' to 'a'.",
"Keep repeating until the frequency of all characters is zero."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().sortString",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:07",
"tests_total": 69,
"tests_dropped"... | typescript | {
"raw_signature": "function sortString(s: string): string {",
"container": null,
"callable": "sortString",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,371 | find-the-longest-substring-containing-vowels-in-even-counts | Medium | Given the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must appear an even number of times.
Example 1:
Input: s = "eleetminicoworoep"
Output: 13
Explanation: The longest substring is "leetminicowor" which contains two each of th... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"bcbcbc\") == 6\n assert candidate(s = \"cbacdcdcdbacdbad\") == 14\n assert candidate(s = \"aeiouaeiouaeiouaeiou\") == 20\n assert candidate(s = \"aaaaaeeeeeiioooouuuu\") == 14\n assert candidate(s = \"abcdefghijklmnopqr... | [
"\"eleetminicoworoep\"",
"\"leetcodeisgreat\"",
"\"bcbcbc\""
] | [
"Represent the counts (odd or even) of vowels with a bitmask.",
"Precompute the prefix xor for the bitmask of vowels and then get the longest valid substring."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().findTheLongestSubstring",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:09",
"tests_total": 77,
"t... | typescript | {
"raw_signature": "function findTheLongestSubstring(s: string): number {",
"container": null,
"callable": "findTheLongestSubstring",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
1,374 | generate-a-string-with-characters-that-have-odd-counts | Easy | Given an integer n, return a string with n characters such that each character in such string occurs an odd number of times.
The returned string must contain only lowercase English letters. If there are multiples valid strings, return any of them.
Example 1:
Input: n = 4
Output: "pppz"
Explanation: "pppz" is a valid... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 250) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | [
"4",
"2",
"7"
] | [
"If n is odd, return a string of size n formed only by 'a', else return string formed with n-1 'a' and 1 'b''."
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().generateTheString",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:15",
"tests_total": 58,
"tests_d... | typescript | {
"raw_signature": "function generateTheString(n: number): string {",
"container": null,
"callable": "generateTheString",
"parameters": [
{
"name": "n",
"type": "number"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
1,375 | number-of-times-binary-string-is-prefix-aligned | Medium | You have a 1-indexed binary string of length n where all the bits are 0 initially. We will flip all the bits of this binary string (i.e., change them from 0 to 1) one by one. You are given a 1-indexed integer array flips where flips[i] indicates that the bit at index flips[i] will be flipped in the i^th step.
A binary... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(flips = [5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 2, 3, 4, 5]) == 5\n assert candidate(flips = [2, 1, 3, 5, 4]) == 3\n assert candidate(flips = [3, 2, 4, 1, 5]) == 2\n assert candidate(flips = [4, 1, 2, 3]) == 1\n ... | [
"[3,2,4,1,5]",
"[4,1,2,3]"
] | [
"If in the step x all bulb shines then bulbs 1,2,3,..,x should shines too."
] | {
"canonical_parameter_names": [
"flips"
],
"leetcode_dataset_entry_point": "Solution().numTimesAllBlue",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:18",
"tests_total": 91,
"tests... | typescript | {
"raw_signature": "function numTimesAllBlue(flips: number[]): number {",
"container": null,
"callable": "numTimesAllBlue",
"parameters": [
{
"name": "flips",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
1,376 | time-needed-to-inform-all-employees | Medium | A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company is the one with headID.
Each employee has one direct manager given in the manager array where manager[i] is the direct manager of the i-th employee, manager[headID] = -1. Also, it is guaranteed that the subordination ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 6,headID = 2,manager = [2, 2, -1, 2, 2, 2],informTime = [0, 0, 1, 0, 0, 0]) == 1\n assert candidate(n = 15,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],informTime = [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,... | [
"1\n0\n[-1]\n[0]",
"6\n2\n[2,2,-1,2,2,2]\n[0,0,1,0,0,0]"
] | [
"The company can be represented as a tree, headID is always the root.",
"Store for each node the time needed to be informed of the news.",
"Answer is the max time a leaf node needs to be informed."
] | {
"canonical_parameter_names": [
"n",
"headID",
"manager",
"informTime"
],
"leetcode_dataset_entry_point": "Solution().numOfMinutes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T... | typescript | {
"raw_signature": "function numOfMinutes(n: number, headID: number, manager: number[], informTime: number[]): number {",
"container": null,
"callable": "numOfMinutes",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "headID",
"type": "number"
},
{
... |
1,377 | frog-position-after-t-seconds | Hard | Given an undirected tree consisting of n vertices numbered from 1 to n. A frog starts jumping from vertex 1. In one second, the frog jumps from its current vertex to another unvisited vertex if they are directly connected. The frog can not jump back to a visited vertex. In case the frog can jump to several vertices, it... | {
"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... | [
"7\n[[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]]\n2\n4",
"7\n[[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]]\n1\n7"
] | [
"Use a variation of DFS with parameters 'curent_vertex' and 'current_time'.",
"Update the probability considering to jump to one of the children vertices."
] | {
"canonical_parameter_names": [
"n",
"edges",
"t",
"target"
],
"leetcode_dataset_entry_point": "Solution().frogPosition",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:23",
... | typescript | {
"raw_signature": "function frogPosition(n: number, edges: number[][], t: number, target: number): number {",
"container": null,
"callable": "frogPosition",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "edges",
"type": "number[][]"
},
{
"name": ... |
1,380 | lucky-numbers-in-a-matrix | Easy | Given an m x n matrix of distinct numbers, return all lucky numbers in the matrix in any order.
A lucky number is an element of the matrix such that it is the minimum element in its row and maximum in its column.
Example 1:
Input: matrix = [[3,7,8],[9,11,13],[15,16,17]]
Output: [15]
Explanation: 15 is the only lucky... | {
"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,7,8],[9,11,13],[15,16,17]]",
"[[1,10,4,2],[9,3,8,7],[15,16,17,12]]",
"[[7,8],[1,2]]"
] | [
"Find out and save the minimum of each row and maximum of each column in two lists.",
"Then scan through the whole matrix to identify the elements that satisfy the criteria."
] | {
"canonical_parameter_names": [
"matrix"
],
"leetcode_dataset_entry_point": "Solution().luckyNumbers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:27",
"tests_total": 87,
"tests_d... | typescript | {
"raw_signature": "function luckyNumbers(matrix: number[][]): number[] {",
"container": null,
"callable": "luckyNumbers",
"parameters": [
{
"name": "matrix",
"type": "number[][]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
1,383 | maximum-performance-of-a-team | Hard | You are given two integers n and k and two integer arrays speed and efficiency both of length n. There are n engineers numbered from 1 to n. speed[i] and efficiency[i] represent the speed and efficiency of the i^th engineer respectively.
Choose at most k different engineers out of the n engineers to form a team with t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 6,speed = [2, 10, 3, 1, 5, 8],efficiency = [5, 4, 3, 9, 7, 2],k = 2) == 60\n assert candidate(n = 6,speed = [2, 10, 3, 1, 5, 8],efficiency = [5, 4, 3, 9, 7, 2],k = 3) == 68\n assert candidate(n = 5,speed = [4, 1, 12, 7, 8],effi... | [
"6\n[2,10,3,1,5,8]\n[5,4,3,9,7,2]\n2",
"6\n[2,10,3,1,5,8]\n[5,4,3,9,7,2]\n3",
"6\n[2,10,3,1,5,8]\n[5,4,3,9,7,2]\n4"
] | [
"Keep track of the engineers by their efficiency in decreasing order.",
"Starting from one engineer, to build a team, it suffices to bring K-1 more engineers who have higher efficiencies as well as high speeds."
] | {
"canonical_parameter_names": [
"n",
"speed",
"efficiency",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxPerformance",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18... | typescript | {
"raw_signature": "function maxPerformance(n: number, speed: number[], efficiency: number[], k: number): number {",
"container": null,
"callable": "maxPerformance",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "speed",
"type": "number[]"
},
{
"n... |
1,385 | find-the-distance-value-between-two-arrays | Easy | Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays.
The distance value is defined as the number of elements arr1[i] such that there is not any element arr2[j] where |arr1[i]-arr2[j]| <= d.
Example 1:
Input: arr1 = [4,5,8], arr2 = [10,9,1,8], d = 2
Output: 2
Ex... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr1 = [10, 20, 30],arr2 = [5, 15, 25],d = 4) == 3\n assert candidate(arr1 = [4, 5, 8],arr2 = [10, 9, 1, 8],d = 2) == 2\n assert candidate(arr1 = [1, 4, 2, 3],arr2 = [-4, -3, 6, 10, 20, 30],d = 3) == 2\n assert candidate(arr1 = ... | [
"[4,5,8]\n[10,9,1,8]\n2",
"[1,4,2,3]\n[-4,-3,6,10,20,30]\n3",
"[2,1,100,3]\n[-5,-2,10,-3,7]\n6"
] | [
"Sort 'arr2' and use binary search to get the closest element for each 'arr1[i]', it gives a time complexity of O(nlogn)."
] | {
"canonical_parameter_names": [
"arr1",
"arr2",
"d"
],
"leetcode_dataset_entry_point": "Solution().findTheDistanceValue",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:34",
"t... | typescript | {
"raw_signature": "function findTheDistanceValue(arr1: number[], arr2: number[], d: number): number {",
"container": null,
"callable": "findTheDistanceValue",
"parameters": [
{
"name": "arr1",
"type": "number[]"
},
{
"name": "arr2",
"type": "number[]"
},
{
"nam... |
1,386 | cinema-seat-allocation | Medium | A cinema has n rows of seats, numbered from 1 to n. Each row has 10 seats, numbered from 1 to 10.
You are given a 2D integer array reservedSeats, where reservedSeats[i] = [row_i, seat_i] means that seat seat_i in row row_i is already reserved.
A four-person group must be assigned to four seats in the same row. The gr... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 8\n assert candidate(n = 4,reservedSeats = [[4, 3], [1, 4], [4, 6], [1, 7]]) == 4\n assert candidate(n = 5,reservedSeats = [[1, 2],... | [
"3\n[[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]",
"2\n[[2,1],[1,8],[2,6]]",
"4\n[[4,3],[1,4],[4,6],[1,7]]"
] | [
"Note you can allocate at most two four-person groups in one row.",
"Greedily check if you can allocate seats for two groups, one group or none.",
"Process only rows that appear in the input, for other rows you can always allocate seats for two groups."
] | {
"canonical_parameter_names": [
"n",
"reservedSeats"
],
"leetcode_dataset_entry_point": "Solution().maxNumberOfFamilies",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:36",
"tests... | typescript | {
"raw_signature": "function maxNumberOfFamilies(n: number, reservedSeats: number[][]): number {",
"container": null,
"callable": "maxNumberOfFamilies",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "reservedSeats",
"type": "number[][]"
}
],
"return_typ... |
1,387 | sort-integers-by-the-power-value | Medium | The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:
- if x is even then x = x / 2
- if x is odd then x = 3 * x + 1
For example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1).
Given three inte... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(lo = 1,hi = 10,k = 1) == 1\n assert candidate(lo = 5,hi = 5,k = 1) == 5\n assert candidate(lo = 12,hi = 15,k = 2) == 13\n assert candidate(lo = 1,hi = 10,k = 5) == 5\n assert candidate(lo = 10,hi = 20,k = 5) == 13\n assert... | [
"12\n15\n2",
"7\n11\n4"
] | [
"Use dynamic programming to get the power of each integer of the intervals.",
"Sort all the integers of the interval by the power value and return the k-th in the sorted list."
] | {
"canonical_parameter_names": [
"lo",
"hi",
"k"
],
"leetcode_dataset_entry_point": "Solution().getKth",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:39",
"tests_total": 93,
... | typescript | {
"raw_signature": "function getKth(lo: number, hi: number, k: number): number {",
"container": null,
"callable": "getKth",
"parameters": [
{
"name": "lo",
"type": "number"
},
{
"name": "hi",
"type": "number"
},
{
"name": "k",
"type": "number"
}
],
... |
1,388 | pizza-with-3n-slices | Hard | There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:
- You will pick any pizza slice.
- Your friend Alice will pick the next slice in the anti-clockwise direction of your pick.
- Your friend Bob will pick the next slice in the clockwise direction of your pick.
- R... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(slices = [9, 7, 7, 7, 6, 6]) == 16\n assert candidate(slices = [1000, 1000, 1000, 1000, 1000, 1000]) == 2000\n assert candidate(slices = [10, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1]) =... | [
"[1,2,3,4,5,6]",
"[8,9,8,6,1,1]"
] | [
"By studying the pattern of the operations, we can find out that the problem is equivalent to: Given an integer array with size 3N, select N integers with maximum sum and any selected integers are not next to each other in the array.",
"The first one in the array is considered next to the last one in the array. U... | {
"canonical_parameter_names": [
"slices"
],
"leetcode_dataset_entry_point": "Solution().maxSizeSlices",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:41",
"tests_total": 111,
"tests... | typescript | {
"raw_signature": "function maxSizeSlices(slices: number[]): number {",
"container": null,
"callable": "maxSizeSlices",
"parameters": [
{
"name": "slices",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
1,389 | create-target-array-in-the-given-order | Easy | Given two arrays of integers nums and index. Your task is to create target array under the following rules:
- Initially target array is empty.
- From left to right read nums[i] and index[i], insert at index index[i] the value nums[i] in target array.
- Repeat the previous step until there are no elements to read in nu... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1],index = [0]) == [1]\n assert candidate(nums = [10, 9, 8, 7, 6],index = [0, 1, 1, 1, 1]) == [10, 6, 7, 8, 9]\n assert candidate(nums = [0, 1, 2, 3, 4],index = [0, 1, 2, 2, 1]) == [0, 4, 1, 3, 2]\n assert candidate(nums... | [
"[0,1,2,3,4]\n[0,1,2,2,1]",
"[1,2,3,4,0]\n[0,1,2,3,0]",
"[1]\n[0]"
] | [
"Simulate the process and fill corresponding numbers in the designated spots."
] | {
"canonical_parameter_names": [
"nums",
"index"
],
"leetcode_dataset_entry_point": "Solution().createTargetArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:43",
"tests_total"... | typescript | {
"raw_signature": "function createTargetArray(nums: number[], index: number[]): number[] {",
"container": null,
"callable": "createTargetArray",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "index",
"type": "number[]"
}
],
"return_type": "number[... |
1,390 | four-divisors | Medium | Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.
Example 1:
Input: nums = [21,4,7]
Output: 32
Explanation:
21 has 4 divisors: 1, 3, 7, 21
4 has 3 divisors: 1, 2, 4
7 has 2 divisors: 1, 7
The answe... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [101, 103, 107, 109, 113]) == 0\n assert candidate(nums = [2310, 2320, 2330, 2340, 2350]) == 0\n assert candidate(nums = [30, 44, 25, 63]) == 0\n assert candidate(nums = [30, 100, 49]) == 0\n assert candidate(nums = [6... | [
"[21,4,7]",
"[21,21]",
"[1,2,3,4,5]"
] | [
"Find the divisors of each element in the array.",
"You only need to loop to the square root of a number to find its divisors."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().sumFourDivisors",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:45",
"tests_total": 136,
"tests... | typescript | {
"raw_signature": "function sumFourDivisors(nums: number[]): number {",
"container": null,
"callable": "sumFourDivisors",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
1,391 | check-if-there-is-a-valid-path-in-a-grid | Medium | You are given an m x n grid. Each cell of grid represents a street. The street of grid[i][j] can be:
- 1 which means a street connecting the left cell and the right cell.
- 2 which means a street connecting the upper cell and the lower cell.
- 3 which means a street connecting the left cell and the lower cell.
- 4 whi... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[4, 3, 2, 1], [2, 1, 4, 3], [3, 2, 1, 4]]) == False\n assert candidate(grid = [[2], [2], [2]]) == True\n assert candidate(grid = [[1, 1, 2]]) == False\n assert candidate(grid = [[2, 4, 3], [6, 5, 2]]) == True\n assert... | [
"[[3],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2],[2]]",
"[[6,2],[3,2],[2,3],[5,6],[4,4],[3,2],[4,4],[2,2],[1,3],[3,5],[6,6],[3,5]... | [
"Start DFS from the node (0, 0) and follow the path till you stop.",
"When you reach a cell and cannot move anymore check that this cell is (m - 1, n - 1) or not."
] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().hasValidPath",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:47",
"tests_total": 77,
"tests_dro... | typescript | {
"raw_signature": "function hasValidPath(grid: number[][]): boolean {",
"container": null,
"callable": "hasValidPath",
"parameters": [
{
"name": "grid",
"type": "number[][]"
}
],
"return_type": "boolean",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
1,392 | longest-happy-prefix | Hard | A string is called a happy prefix if it is a non-empty prefix which is also a suffix (excluding itself).
Given a string s, return the longest happy prefix of s. Return an empty string "" if no such prefix exists.
Example 1:
Input: s = "level"
Output: "l"
Explanation: s contains 4 prefix excluding itself ("l", "le", ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"prefixprefix\") == \"prefix\"\n assert candidate(s = \"abcdef\") == \"\"\n assert candidate(s = \"aaaaa\") == \"aaaa\"\n assert candidate(s = \"aaaaabaaaa\") == \"aaaa\"\n assert candidate(s = \"a\") == \"\"\n assert... | [
"\"level\"",
"\"ababab\""
] | [
"Use Longest Prefix Suffix (KMP-table) or String Hashing."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().longestPrefix",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:50",
"tests_total": 162,
"tests_drop... | typescript | {
"raw_signature": "function longestPrefix(s: string): string {",
"container": null,
"callable": "longestPrefix",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,394 | find-lucky-integer-in-an-array | Easy | Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value.
Return the largest lucky integer in the array. If there is no lucky integer return -1.
Example 1:
Input: arr = [2,2,3,4]
Output: 2
Explanation: The only lucky number in the array is 2 because frequency... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [1, 1]) == -1\n assert candidate(arr = [5, 5, 4, 4, 4]) == -1\n assert candidate(arr = [5]) == -1\n assert candidate(arr = [5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [2, 2, 3, 4]) == 2\n assert candidate(arr = [3... | [
"[2,2,3,4]",
"[1,2,2,3,3,3]",
"[2,2,2,3,3]"
] | [
"Count the frequency of each integer in the array.",
"Get all lucky numbers and return the largest of them."
] | {
"canonical_parameter_names": [
"arr"
],
"leetcode_dataset_entry_point": "Solution().findLucky",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:52",
"tests_total": 61,
"tests_dropped... | typescript | {
"raw_signature": "function findLucky(arr: number[]): number {",
"container": null,
"callable": "findLucky",
"parameters": [
{
"name": "arr",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,395 | count-number-of-teams | Medium | There are n soldiers standing in a line. Each soldier is assigned a unique rating value.
You have to form a team of 3 soldiers amongst them under the following rules:
- Choose 3 soldiers with index (i, j, k) with rating (rating[i], rating[j], rating[k]).
- A team is valid if: (rating[i] < rating[j] < rating[k]) or (r... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(rating = [2, 1, 3]) == 0\n assert candidate(rating = [3, 1, 2, 5, 4]) == 2\n assert candidate(rating = [1, 5, 2, 4, 3]) == 3\n assert candidate(rating = [10, 6, 5, 8]) == 1\n assert candidate(rating = [5, 4, 3, 2, 1]) == 10\n... | [
"[2,5,3,4,1]",
"[2,1,3]",
"[1,2,3,4]"
] | [
"BruteForce, check all possibilities."
] | {
"canonical_parameter_names": [
"rating"
],
"leetcode_dataset_entry_point": "Solution().numTeams",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:54",
"tests_total": 114,
"tests_drop... | typescript | {
"raw_signature": "function numTeams(rating: number[]): number {",
"container": null,
"callable": "numTeams",
"parameters": [
{
"name": "rating",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,397 | find-all-good-strings | Hard | Given the strings s1 and s2 of size n and the string evil, return the number of good strings.
A good string has size n, it is alphabetically greater than or equal to s1, it is alphabetically smaller than or equal to s2, and it does not contain the string evil as a substring. Since the answer can be a huge number, retu... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 5,s1 = \"apple\",s2 = \"zebra\",evil = \"app\") == 11220078\n assert candidate(n = 3,s1 = \"aaa\",s2 = \"zzz\",evil = \"abc\") == 17575\n assert candidate(n = 5,s1 = \"aaaaa\",s2 = \"zzzzz\",evil = \"abc\") == 11879348\n ass... | [
"2\n\"aa\"\n\"da\"\n\"b\"",
"8\n\"leetcode\"\n\"leetgoes\"\n\"leet\"",
"2\n\"gx\"\n\"gz\"\n\"x\""
] | [
"Use DP with 4 states (pos: Int, posEvil: Int, equalToS1: Bool, equalToS2: Bool) which compute the number of valid strings of size \"pos\" where the maximum common suffix with string \"evil\" has size \"posEvil\". When \"equalToS1\" is \"true\", the current valid string is equal to \"S1\" otherwise it is greater. I... | {
"canonical_parameter_names": [
"n",
"s1",
"s2",
"evil"
],
"leetcode_dataset_entry_point": "Solution().findGoodStrings",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:57",
... | typescript | {
"raw_signature": "function findGoodStrings(n: number, s1: string, s2: string, evil: string): number {",
"container": null,
"callable": "findGoodStrings",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "s1",
"type": "string"
},
{
"name": "s2",
... |
1,399 | count-largest-group | Easy | You are given an integer n.
We need to group the numbers from 1 to n according to the sum of its digits. For example, the numbers 14 and 5 belong to the same group, whereas 13 and 3 belong to different groups.
Return the number of groups that have the largest size, i.e. the maximum number of elements.
Example 1:
In... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 200) == 2\n assert candidate(n = 10000) == 1\n assert candidate(n = 9) == 9\n assert candidate(n = 104) == 1\n assert candidate(n = 9999) == 1\n assert candidate(n = 2) == 2\n assert candidate(n = 100) == 1\n ass... | [
"13",
"2"
] | [
"Count the digit sum for each integer in the range and find out the largest groups."
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().countLargestGroup",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:18:59",
"tests_total": 45,
"tests_d... | typescript | {
"raw_signature": "function countLargestGroup(n: number): number {",
"container": null,
"callable": "countLargestGroup",
"parameters": [
{
"name": "n",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
1,400 | construct-k-palindrome-strings | Medium | Given a string s and an integer k, return true if you can use all the characters in s to construct non-empty k palindrome strings or false otherwise.
Example 1:
Input: s = "annabelle", k = 2
Output: true
Explanation: You can construct two palindromes using all characters in s.
Some possible constructions "anna" + "el... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"a\",k = 2) == False\n assert candidate(s = \"aabbcc\",k = 3) == True\n assert candidate(s = \"abcd\",k = 2) == False\n assert candidate(s = \"yzyzyzyzyzyzyzy\",k = 17) == False\n assert candidate(s = \"true\",k = 4) == ... | [
"\"annabelle\"\n2",
"\"leetcode\"\n3",
"\"true\"\n4"
] | [
"If the s.length < k we cannot construct k strings from s and answer is false.",
"If the number of characters that have odd counts is > k then the minimum number of palindrome strings we can construct is > k and answer is false.",
"Otherwise you can construct exactly k palindrome strings and answer is true (why... | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().canConstruct",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:01",
"tests_total": 100,
"te... | typescript | {
"raw_signature": "function canConstruct(s: string, k: number): boolean {",
"container": null,
"callable": "canConstruct",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "boolean",
"signature_source": "leetcod... |
1,401 | circle-and-rectangle-overlapping | Medium | You are given a circle represented as (radius, xCenter, yCenter) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.
Return true if the circle and rectangle are overlapped... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(radius = 3,xCenter = -3,yCenter = -4,x1 = -6,y1 = -6,x2 = -2,y2 = -2) == True\n assert candidate(radius = 2,xCenter = -2,yCenter = -2,x1 = -5,y1 = -5,x2 = -3,y2 = -3) == True\n assert candidate(radius = 5,xCenter = 0,yCenter = 0,x1... | [
"1\n0\n0\n1\n-1\n3\n1",
"1\n1\n1\n1\n-3\n2\n-1",
"1\n0\n0\n-1\n0\n0\n1"
] | [
"Locate the closest point of the square to the circle, you can then find the distance from this point to the center of the circle and check if this is less than or equal to the radius."
] | {
"canonical_parameter_names": [
"radius",
"xCenter",
"yCenter",
"x1",
"y1",
"x2",
"y2"
],
"leetcode_dataset_entry_point": "Solution().checkOverlap",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
... | typescript | {
"raw_signature": "function checkOverlap(radius: number, xCenter: number, yCenter: number, x1: number, y1: number, x2: number, y2: number): boolean {",
"container": null,
"callable": "checkOverlap",
"parameters": [
{
"name": "radius",
"type": "number"
},
{
"name": "xCenter",
... |
1,402 | reducing-dishes | Hard | A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time.
Like-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. time[i] * satisfaction[i].
Return the maximum sum of like-ti... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(satisfaction = [1, -1, 2, -2, 3, -3]) == 22\n assert candidate(satisfaction = [0]) == 0\n assert candidate(satisfaction = [-1]) == 0\n assert candidate(satisfaction = [-500, -500, -500, -500, -500]) == 0\n assert candidate(sa... | [
"[-1,-8,0,5,-7]",
"[4,3,2]",
"[-1,-4,-5]"
] | [
"Use dynamic programming to find the optimal solution by saving the previous best like-time coefficient and its corresponding element sum.",
"If adding the current element to the previous best like-time coefficient and its corresponding element sum would increase the best like-time coefficient, then go ahead and ... | {
"canonical_parameter_names": [
"satisfaction"
],
"leetcode_dataset_entry_point": "Solution().maxSatisfaction",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:06",
"tests_total": 114,
... | typescript | {
"raw_signature": "function maxSatisfaction(satisfaction: number[]): number {",
"container": null,
"callable": "maxSatisfaction",
"parameters": [
{
"name": "satisfaction",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "l... |
1,403 | minimum-subsequence-in-non-increasing-order | Easy | Given the array nums, obtain a subsequence of the array whose sum of elements is strictly greater than the sum of the non included elements in such subsequence.
If there are multiple solutions, return the subsequence with minimum size and if there still exist multiple solutions, return the subsequence with the maximum... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [4, 4, 7, 6, 7]) == [7, 7, 6]\n assert candidate(nums = [100, 90, 80, 70, 60]) == [100, 90, 80]\n assert candidate(nums = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100]\n assert candidate(nums = ... | [
"[4,3,10,9,8]",
"[4,4,7,6,7]"
] | [
"Sort elements and take each element from the largest until accomplish the conditions."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().minSubsequence",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:08",
"tests_total": 60,
"tests_d... | typescript | {
"raw_signature": "function minSubsequence(nums: number[]): number[] {",
"container": null,
"callable": "minSubsequence",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
1,404 | number-of-steps-to-reduce-a-number-in-binary-representation-to-one | Medium | Given the binary representation of an integer as a string s, return the number of steps to reduce it to 1 under the following rules:
-
If the current number is even, you have to divide it by 2.
-
If the current number is odd, you have to add 1 to it.
It is guaranteed that you can always reach one for all test cases.
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"11101110111\") == 14\n assert candidate(s = \"1111\") == 5\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101\") == 95\n assert candidate(s = \"1100110\") == 10\n assert candidate(s... | [
"\"1101\"",
"\"10\"",
"\"1\""
] | [
"Read the string from right to left, if the string ends in '0' then the number is even otherwise it is odd.",
"Simulate the steps described in the binary string."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().numSteps",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:10",
"tests_total": 101,
"tests_dropped":... | typescript | {
"raw_signature": "function numSteps(s: string): number {",
"container": null,
"callable": "numSteps",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,405 | longest-happy-string | Medium | A string s is called happy if it satisfies the following conditions:
- s only contains the letters 'a', 'b', and 'c'.
- s does not contain any of "aaa", "bbb", or "ccc" as a substring.
- s contains at most a occurrences of the letter 'a'.
- s contains at most b occurrences of the letter 'b'.
- s contains at most c occ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(a = 7,b = 1,c = 0) == \"aabaa\"\n assert candidate(a = 100,b = 100,c = 100) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc... | [
"1\n1\n7",
"7\n1\n0"
] | [
"Use a greedy approach.",
"Use the letter with the maximum current limit that can be added without breaking the condition."
] | {
"canonical_parameter_names": [
"a",
"b",
"c"
],
"leetcode_dataset_entry_point": "Solution().longestDiverseString",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:12",
"tests_t... | typescript | {
"raw_signature": "function longestDiverseString(a: number, b: number, c: number): string {",
"container": null,
"callable": "longestDiverseString",
"parameters": [
{
"name": "a",
"type": "number"
},
{
"name": "b",
"type": "number"
},
{
"name": "c",
"type... |
1,406 | stone-game-iii | Hard | Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.
Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2, or 3 stones from the firs... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(stoneValue = [0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [1]) == \"Alice\"\n assert candidate(stoneValue = [1, -100, 1, 100]) == \"Tie\"\n assert candidate(stoneValue = [5, 3, 7, 1]) == \"Alice\"\n assert cand... | [
"[1,2,3,7]",
"[1,2,3,-9]",
"[1,2,3,6]"
] | [
"The game can be mapped to minmax game. Alice tries to maximize the total score and Bob tries to minimize it.",
"Use dynamic programming to simulate the game. If the total score was 0 the game is \"Tie\", and if it has positive value then \"Alice\" wins, otherwise \"Bob\" wins."
] | {
"canonical_parameter_names": [
"stoneValue"
],
"leetcode_dataset_entry_point": "Solution().stoneGameIII",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:14",
"tests_total": 102,
"te... | typescript | {
"raw_signature": "function stoneGameIII(stoneValue: number[]): string {",
"container": null,
"callable": "stoneGameIII",
"parameters": [
{
"name": "stoneValue",
"type": "number[]"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
1,408 | string-matching-in-an-array | Easy | Given an array of string words, return all strings in words that are a substring of another word. You can return the answer in any order.
Example 1:
Input: words = ["mass","as","hero","superhero"]
Output: ["as","hero"]
Explanation: "as" is substring of "mass" and "hero" is substring of "superhero".
["hero","as"] is 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 ... | [
"[\"mass\",\"as\",\"hero\",\"superhero\"]",
"[\"leetcode\",\"et\",\"code\"]",
"[\"blue\",\"green\",\"bu\"]"
] | [
"Bruteforce to find if one string is substring of another or use KMP algorithm."
] | {
"canonical_parameter_names": [
"words"
],
"leetcode_dataset_entry_point": "Solution().stringMatching",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:17",
"tests_total": 97,
"tests_... | typescript | {
"raw_signature": "function stringMatching(words: string[]): string[] {",
"container": null,
"callable": "stringMatching",
"parameters": [
{
"name": "words",
"type": "string[]"
}
],
"return_type": "string[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
1,409 | queries-on-a-permutation-with-key | Medium | Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the following rules:
- In the beginning, you have the permutation P=[1,2,3,...,m].
- For the current i, find the position of queries[i] in the permutation P (indexing from 0) a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(queries = [3, 1, 2, 1],m = 5) == [2, 1, 2, 1]\n assert candidate(queries = [1, 2, 3],m = 3) == [0, 1, 2]\n assert candidate(queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(q... | [
"[3,1,2,1]\n5",
"[4,1,2,2]\n4",
"[7,5,5,8,3]\n8"
] | [
"Create the permutation P=[1,2,...,m], it could be a list for example.",
"For each i, find the position of queries[i] with a simple scan over P and then move this to the beginning."
] | {
"canonical_parameter_names": [
"queries",
"m"
],
"leetcode_dataset_entry_point": "Solution().processQueries",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:19",
"tests_total": 97... | typescript | {
"raw_signature": "function processQueries(queries: number[], m: number): number[] {",
"container": null,
"callable": "processQueries",
"parameters": [
{
"name": "queries",
"type": "number[]"
},
{
"name": "m",
"type": "number"
}
],
"return_type": "number[]",
"signa... |
1,411 | number-of-ways-to-paint-n-3-grid | Hard | You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colors: Red, Yellow, or Green while making sure that no two adjacent cells have the same color (i.e., no two cells that share vertical or horizontal sides have the same color).
Given n the number of rows of the grid... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 3) == 246\n assert candidate(n = 1000) == 650420578\n assert candidate(n = 100) == 905790447\n assert candidate(n = 2500) == 80958521\n assert candidate(n = 4) == 1122\n assert candidate(n = 4999) == 134620719\n ass... | [
"1",
"5000"
] | [
"We will use Dynamic programming approach. we will try all possible configuration.",
"Let dp[idx][prev1col][prev2col][prev3col] be the number of ways to color the rows of the grid from idx to n-1 keeping in mind that the previous row (idx - 1) has colors prev1col, prev2col and prev3col. Build the dp array to get ... | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().numOfWays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:23",
"tests_total": 37,
"tests_dropped":... | typescript | {
"raw_signature": "function numOfWays(n: number): number {",
"container": null,
"callable": "numOfWays",
"parameters": [
{
"name": "n",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,413 | minimum-value-to-get-positive-step-by-step-sum | Easy | Given an array of integers nums, you start with an initial positive value startValue.
In each iteration, you calculate the step by step sum of startValue plus elements in nums (from left to right).
Return the minimum positive value of startValue such that the step by step sum is never less than 1.
Example 1:
Input:... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [-1, 1, -1, 1]) == 2\n assert candidate(nums = [100, 100, 100]) == 1\n assert candidate(nums = [-3, 2, -3, 4, 2]) == 5\n assert candidate(nums = [1, -2, -3]) == 5\n assert candidate(nums = [-1]) == 2\n assert candid... | [
"[-3,2,-3,4,2]",
"[1,2]",
"[1,-2,-3]"
] | [
"Find the minimum prefix sum."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().minStartValue",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:26",
"tests_total": 95,
"tests_dr... | typescript | {
"raw_signature": "function minStartValue(nums: number[]): number {",
"container": null,
"callable": "minStartValue",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
1,414 | find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k | Medium | Given an integer k, return the minimum number of Fibonacci numbers whose sum is equal to k. The same Fibonacci number can be used multiple times.
The Fibonacci numbers are defined as:
- F_1 = 1
- F_2 = 1
- F_n = F_{n-1} + F_{n-2} for n > 2.
It is guaranteed that for the given constraints we can always find such Fibo... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(k = 433494437) == 1\n assert candidate(k = 377) == 1\n assert candidate(k = 6765) == 1\n assert candidate(k = 24157817) == 1\n assert candidate(k = 102334155) == 1\n assert candidate(k = 89) == 1\n assert candidate(k = ... | [
"7",
"10",
"19"
] | [
"Generate all Fibonacci numbers up to the limit (they are few).",
"Use greedy solution, taking at every time the greatest Fibonacci number which is smaller than or equal to the current number. Subtract this Fibonacci number from the current number and repeat again the process."
] | {
"canonical_parameter_names": [
"k"
],
"leetcode_dataset_entry_point": "Solution().findMinFibonacciNumbers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:28",
"tests_total": 70,
"t... | typescript | {
"raw_signature": "function findMinFibonacciNumbers(k: number): number {",
"container": null,
"callable": "findMinFibonacciNumbers",
"parameters": [
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
1,415 | the-k-th-lexicographical-string-of-all-happy-strings-of-length-n | Medium | A happy string is a string that:
- consists only of letters of the set ['a', 'b', 'c'].
- s[i] != s[i + 1] for all values of i from 1 to s.length - 1 (string is 1-indexed).
For example, strings "abc", "ac", "b" and "abcbabcbcb" are all happy strings and strings "aa", "baa" and "ababbc" are not happy strings.
Given t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 5,k = 1) == \"ababa\"\n assert candidate(n = 10,k = 100) == \"abacbabacb\"\n assert candidate(n = 1,k = 4) == \"\"\n assert candidate(n = 2,k = 5) == \"ca\"\n assert candidate(n = 5,k = 25) == \"bcaba\"\n assert candid... | [
"1\n3",
"1\n4",
"3\n9"
] | [
"Generate recursively all the happy strings of length n.",
"Sort them in lexicographical order and return the kth string if it exists."
] | {
"canonical_parameter_names": [
"n",
"k"
],
"leetcode_dataset_entry_point": "Solution().getHappyString",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:30",
"tests_total": 78,
"t... | typescript | {
"raw_signature": "function getHappyString(n: number, k: number): string {",
"container": null,
"callable": "getHappyString",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "string",
"signature_source": "leetc... |
1,416 | restore-the-array | Hard | A program was supposed to print an array of integers. The program forgot to print whitespaces and the array is printed as a string of digits s and all we know is that all integers in the array were in the range [1, k] and there are no leading zeros in the array.
Given the string s and the integer k, return the number ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"237\",k = 50) == 3\n assert candidate(s = \"111111111111111111111\",k = 11) == 17711\n assert candidate(s = \"123123123\",k = 123) == 100\n assert candidate(s = \"1317\",k = 2000) == 8\n assert candidate(s = \"99999\",k... | [
"\"1000\"\n10000",
"\"1000\"\n10",
"\"1317\"\n2000"
] | [
"Use dynamic programming. Build an array dp where dp[i] is the number of ways you can divide the string starting from index i to the end.",
"Keep in mind that the answer is modulo 10^9 + 7 and take the mod for each operation."
] | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().numberOfArrays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:32",
"tests_total": 104,
"... | typescript | {
"raw_signature": "function numberOfArrays(s: string, k: number): number {",
"container": null,
"callable": "numberOfArrays",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetc... |
1,417 | reformat-the-string | Easy | You are given an alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits).
You have to find a permutation of the string where no letter is followed by another letter and no digit is followed by another digit. That is, no two adjacent characters have the same type.
Re... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"a1b1\") == \"a1b1\"\n assert candidate(s = \"1229857369\") == \"\"\n assert candidate(s = \"aa1\") == \"a1a\"\n assert candidate(s = \"abc123def456\") == \"a1b2c3d4e5f6\"\n assert candidate(s = \"0123456789abcdefghijklm... | [
"\"a0b1c2\"",
"\"leetcode\"",
"\"1229857369\""
] | [
"Count the number of letters and digits in the string. if cntLetters - cntDigits has any of the values [-1, 0, 1] we have an answer, otherwise we don't have any answer.",
"Build the string anyway as you wish. Keep in mind that you need to start with the type that has more characters if cntLetters ≠ cntDigits."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().reformat",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:34",
"tests_total": 136,
"tests_dropped":... | typescript | {
"raw_signature": "function reformat(s: string): string {",
"container": null,
"callable": "reformat",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,418 | display-table-of-food-orders-in-a-restaurant | Medium | Given the array orders, which represents the orders that customers have done in a restaurant. More specifically orders[i]=[customerName_i,tableNumber_i,foodItem_i] where customerName_i is the name of the customer, tableNumber_i is the table customer sit at, and foodItem_i is the item customer orders.
Return the restau... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(orders = [['Alice', '2', 'Veggie Delight'], ['Bob', '1', 'Salmon'], ['Charlie', '2', 'Salmon'], ['David', '3', 'Veggie Delight'], ['Eve', '3', 'Salmon']]) == [['Table', 'Salmon', 'Veggie Delight'], ['1', '1', '0'], ['2', '1', '1'], ['3',... | [
"[[\"David\",\"3\",\"Ceviche\"],[\"Corina\",\"10\",\"Beef Burrito\"],[\"David\",\"3\",\"Fried Chicken\"],[\"Carla\",\"5\",\"Water\"],[\"Carla\",\"5\",\"Ceviche\"],[\"Rous\",\"3\",\"Ceviche\"]]",
"[[\"James\",\"12\",\"Fried Chicken\"],[\"Ratesh\",\"12\",\"Fried Chicken\"],[\"Amadeus\",\"12\",\"Fried Chicken\"],[\"... | [
"Keep the frequency of all pairs (tableNumber, foodItem) using a hashmap.",
"Sort rows by tableNumber and columns by foodItem, then process the resulted table."
] | {
"canonical_parameter_names": [
"orders"
],
"leetcode_dataset_entry_point": "Solution().displayTable",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:37",
"tests_total": 53,
"tests_d... | typescript | {
"raw_signature": "function displayTable(orders: string[][]): string[][] {",
"container": null,
"callable": "displayTable",
"parameters": [
{
"name": "orders",
"type": "string[][]"
}
],
"return_type": "string[][]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcod... |
1,419 | minimum-number-of-frogs-croaking | Medium | You are given the string croakOfFrogs, which represents a combination of the string "croak" from different frogs, that is, multiple frogs can croak at the same time, so multiple "croak" are mixed.
Return the minimum number of different frogs to finish all the croaks in the given string.
A valid "croak" means a frog i... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(croakOfFrogs = \"croakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"croak\") == 1\n assert candidate(croakOfFrogs = \"cccrroooaaakkk\") == -1\n assert candidate(croakOfFrogs = \"crcoakroak\") == 2\n assert candidate(... | [
"\"croakcroak\"",
"\"crcoakroak\"",
"\"croakcrook\""
] | [
"keep the frequency of all characters from \"croak\" using a hashmap.",
"For each character in the given string, greedily match it to a possible \"croak\"."
] | {
"canonical_parameter_names": [
"croakOfFrogs"
],
"leetcode_dataset_entry_point": "Solution().minNumberOfFrogs",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:39",
"tests_total": 197,... | typescript | {
"raw_signature": "function minNumberOfFrogs(croakOfFrogs: string): number {",
"container": null,
"callable": "minNumberOfFrogs",
"parameters": [
{
"name": "croakOfFrogs",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "lee... |
1,420 | build-array-where-you-can-find-the-maximum-exactly-k-comparisons | Hard | You are given three integers n, m and k. Consider the following algorithm to find the maximum element of an array of positive integers:
You should build the array arr which has the following properties:
- arr has exactly n integers.
- 1 <= arr[i] <= m where (0 <= i < n).
- After applying the mentioned algorithm to ar... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 1,m = 1,k = 1) == 1\n assert candidate(n = 4,m = 5,k = 2) == 305\n assert candidate(n = 3,m = 3,k = 0) == 0\n assert candidate(n = 3,m = 5,k = 2) == 60\n assert candidate(n = 5,m = 2,k = 3) == 0\n assert candidate(n = ... | [
"2\n3\n1",
"5\n2\n3",
"9\n1\n1"
] | [
"Use dynamic programming approach. Build dp table where dp[a][b][c] is the number of ways you can start building the array starting from index a where the search_cost = c and the maximum used integer was b.",
"Recursively, solve the small sub-problems first. Optimize your answer by stopping the search if you exce... | {
"canonical_parameter_names": [
"n",
"m",
"k"
],
"leetcode_dataset_entry_point": "Solution().numOfArrays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:41",
"tests_total": 10... | typescript | {
"raw_signature": "function numOfArrays(n: number, m: number, k: number): number {",
"container": null,
"callable": "numOfArrays",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "m",
"type": "number"
},
{
"name": "k",
"type": "number"
}
... |
1,422 | maximum-score-after-splitting-a-string | Easy | Given a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e. left substring and right substring).
The score after splitting a string is the number of zeros in the left substring plus the number of ones in the right substring.
Example 1:
Input: s = "01110... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"1111\") == 3\n assert candidate(s = \"00111\") == 5\n assert candidate(s = \"100100\") == 3\n assert candidate(s = \"110011\") == 4\n assert candidate(s = \"001001\") == 5\n assert candidate(s = \"11110000\") == 3\n ... | [
"\"011101\"",
"\"00111\"",
"\"1111\""
] | [
"Precompute a prefix sum of ones ('1').",
"Iterate from left to right counting the number of zeros ('0'), then use the precomputed prefix sum for counting ones ('1'). Update the answer."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().maxScore",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:43",
"tests_total": 143,
"tests_dropped":... | typescript | {
"raw_signature": "function maxScore(s: string): number {",
"container": null,
"callable": "maxScore",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,423 | maximum-points-you-can-obtain-from-cards | Medium | There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints.
In one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards.
Your score is the sum of the points of the cards you ha... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(cardPoints = [5, 2, 1, 2, 5],k = 3) == 12\n assert candidate(cardPoints = [9, 7, 7, 9, 7, 7, 9],k = 7) == 55\n assert candidate(cardPoints = [1, 1000, 1],k = 1) == 1\n assert candidate(cardPoints = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1... | [
"[1,2,3,4,5,6,1]\n3",
"[2,2,2]\n2",
"[9,7,7,9,7,7,9]\n7"
] | [
"Let the sum of all points be total_pts. You need to remove a sub-array from cardPoints with length n - k.",
"Keep a window of size n - k over the array. The answer is max(answer, total_pts - sumOfCurrentWindow)"
] | {
"canonical_parameter_names": [
"cardPoints",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxScore",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:46",
"tests_total": 78,
... | typescript | {
"raw_signature": "function maxScore(cardPoints: number[], k: number): number {",
"container": null,
"callable": "maxScore",
"parameters": [
{
"name": "cardPoints",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_sourc... |
1,424 | diagonal-traverse-ii | Medium | Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.
Example 1:
Input: nums = [[1,2,3],[4,5,6],[7,8,9]]
Output: [1,4,2,7,5,3,8,6,9]
Example 2:
Input: nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]]
Output: [1,6,2,8,7,3,9,4,12,10,5,13,11,14,15,16]
Cons... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [[1]]) == [1]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == [1, 4, 2, 7, 5, 3, 8, 6, 9]\n assert candidate(nums = [[1, 2, 3], [4, 5], [6]]) == [1, 4, 2, 6, 5, 3]\n assert candidate(nums = [[1, 2, 3, 4, 5... | [
"[[1,2,3],[4,5,6],[7,8,9]]",
"[[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]]"
] | [
"Notice that numbers with equal sums of row and column indexes belong to the same diagonal.",
"Store them in tuples (sum, row, val), sort them, and then regroup the answer."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().findDiagonalOrder",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:48",
"tests_total": 70,
"test... | typescript | {
"raw_signature": "function findDiagonalOrder(nums: number[][]): number[] {",
"container": null,
"callable": "findDiagonalOrder",
"parameters": [
{
"name": "nums",
"type": "number[][]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetc... |
1,425 | constrained-subsequence-sum | Hard | Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums[i] and nums[j], where i < j, the condition j - i <= k is satisfied.
A subsequence of an array is obtained by deleting some number of elemen... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 7, -3, 5],k = 1) == 14\n assert candidate(nums = [10, 2, -10, 5, 20],k = 2) == 37\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 15\n assert candidate(nums = [3, -1, 4, -2, 2, 1],k = 2) == 10\n assert candidat... | [
"[10,2,-10,5,20]\n2",
"[-1,-2,-3]\n1",
"[10,-2,-10,-5,20]\n2"
] | [
"Use dynamic programming.",
"Let dp[i] be the solution for the prefix of the array that ends at index i, if the element at index i is in the subsequence.",
"dp[i] = nums[i] + max(0, dp[i-k], dp[i-k+1], ..., dp[i-1])",
"Use a heap with the sliding window technique to optimize the dp."
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().constrainedSubsetSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:50",
"tests_total":... | typescript | {
"raw_signature": "function constrainedSubsetSum(nums: number[], k: number): number {",
"container": null,
"callable": "constrainedSubsetSum",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"sig... |
1,431 | kids-with-the-greatest-number-of-candies | Easy | There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the i^th kid has, and an integer extraCandies, denoting the number of extra candies that you have.
Return a boolean array result of length n, where result[i] is true if, after giving the i^th k... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(candies = [4, 2, 1, 1, 2],extraCandies = 1) == [True, False, False, False, False]\n assert candidate(candies = [12, 1, 12],extraCandies = 10) == [True, False, True]\n assert candidate(candies = [50, 50, 50, 50, 50],extraCandies = 5... | [
"[2,3,5,1,3]\n3",
"[4,2,1,1,2]\n1",
"[12,1,12]\n10"
] | [
"For each kid check if candies[i] + extraCandies ≥ maximum in Candies[i]."
] | {
"canonical_parameter_names": [
"candies",
"extraCandies"
],
"leetcode_dataset_entry_point": "Solution().kidsWithCandies",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:19:59",
"test... | typescript | {
"raw_signature": "function kidsWithCandies(candies: number[], extraCandies: number): boolean[] {",
"container": null,
"callable": "kidsWithCandies",
"parameters": [
{
"name": "candies",
"type": "number[]"
},
{
"name": "extraCandies",
"type": "number"
}
],
"return_ty... |
1,432 | max-difference-you-can-get-from-changing-an-integer | Medium | You are given an integer num. You will apply the following steps to num two separate times:
- Pick a digit x (0 <= x <= 9).
- Pick another digit y (0 <= y <= 9). Note y can be equal to x.
- Replace all the occurrences of x in the decimal representation of num by y.
Let a and b be the two results from applying the ope... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = 1001100) == 8008800\n assert candidate(num = 9) == 8\n assert candidate(num = 98789) == 81018\n assert candidate(num = 123456) == 820000\n assert candidate(num = 1000000) == 8000000\n assert candidate(num = 1221) == ... | [
"555",
"9"
] | [
"We need to get the max and min value after changing num and the answer is max - min.",
"Use brute force, try all possible changes and keep the minimum and maximum values."
] | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().maxDiff",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:01",
"tests_total": 81,
"tests_dropped":... | typescript | {
"raw_signature": "function maxDiff(num: number): number {",
"container": null,
"callable": "maxDiff",
"parameters": [
{
"name": "num",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,433 | check-if-a-string-can-break-another-string | Medium | Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa. In other words s2 can break s1 or vice-versa.
A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.
Example 1:
I... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s1 = \"same\",s2 = \"same\") == True\n assert candidate(s1 = \"abc\",s2 = \"bca\") == True\n assert candidate(s1 = \"hello\",s2 = \"bello\") == True\n assert candidate(s1 = \"aazz\",s2 = \"zzaa\") == True\n assert candidate(s... | [
"\"abc\"\n\"xya\"",
"\"abe\"\n\"acd\"",
"\"leetcodee\"\n\"interview\""
] | [
"Sort both strings and then check if one of them can break the other."
] | {
"canonical_parameter_names": [
"s1",
"s2"
],
"leetcode_dataset_entry_point": "Solution().checkIfCanBreak",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:04",
"tests_total": 120,
... | typescript | {
"raw_signature": "function checkIfCanBreak(s1: string, s2: string): boolean {",
"container": null,
"callable": "checkIfCanBreak",
"parameters": [
{
"name": "s1",
"type": "string"
},
{
"name": "s2",
"type": "string"
}
],
"return_type": "boolean",
"signature_source"... |
1,434 | number-of-ways-to-wear-different-hats-to-each-other | Hard | There are n people and 40 types of hats labeled from 1 to 40.
Given a 2D integer array hats, where hats[i] is a list of all hats preferred by the i^th person.
Return the number of ways that n people can wear different hats from each other.
Since the answer may be too large, return it modulo 10^9 + 7.
Example 1:
In... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(hats = [[1, 2], [3, 4], [5, 6]]) == 8\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 40\n asse... | [
"[[3,4],[4,5],[5]]",
"[[3,5,1],[3,5]]",
"[[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]"
] | [
"Dynamic programming + bitmask.",
"dp(peopleMask, idHat) number of ways to wear different hats given a bitmask (people visited) and used hats from 1 to idHat-1."
] | {
"canonical_parameter_names": [
"hats"
],
"leetcode_dataset_entry_point": "Solution().numberWays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:06",
"tests_total": 83,
"tests_dropp... | typescript | {
"raw_signature": "function numberWays(hats: number[][]): number {",
"container": null,
"callable": "numberWays",
"parameters": [
{
"name": "hats",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
1,436 | destination-city | Easy | You are given the array paths, where paths[i] = [cityA_i, cityB_i] means there exists a direct path going from cityA_i to cityB_i. Return the destination city, that is, the city without any path outgoing to another city.
It is guaranteed that the graph of paths forms a line without any loop, therefore, there will be e... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(paths = [['X', 'Y'], ['Y', 'Z'], ['Z', 'W']]) == \"W\"\n assert candidate(paths = [['Paris', 'Berlin'], ['Berlin', 'Madrid'], ['Madrid', 'Rome']]) == \"Rome\"\n assert candidate(paths = [['B', 'C'], ['D', 'B'], ['C', 'A']]) == \"A\... | [
"[[\"London\",\"New York\"],[\"New York\",\"Lima\"],[\"Lima\",\"Sao Paulo\"]]",
"[[\"B\",\"C\"],[\"D\",\"B\"],[\"C\",\"A\"]]",
"[[\"A\",\"Z\"]]"
] | [
"Start in any city and use the path to move to the next city.",
"Eventually, you will reach a city with no path outgoing, this is the destination city."
] | {
"canonical_parameter_names": [
"paths"
],
"leetcode_dataset_entry_point": "Solution().destCity",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:08",
"tests_total": 74,
"tests_droppe... | typescript | {
"raw_signature": "function destCity(paths: string[][]): string {",
"container": null,
"callable": "destCity",
"parameters": [
{
"name": "paths",
"type": "string[][]"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,437 | check-if-all-1s-are-at-least-length-k-places-away | Easy | Given an binary array nums and an integer k, return true if all 1's are at least k places away from each other, otherwise return false.
Example 1:
Input: nums = [1,0,0,0,1,0,0,1], k = 2
Output: true
Explanation: Each of the 1s are at least 2 places away from each other.
Example 2:
Input: nums = [1,0,0,1,0,1], k = 2... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 1, 0, 0, 0, 0],k = 1) == False\n assert candidate(nums = [0, 1, 0, 1, 0, 1],k = 1) == True\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],k = 2) == True\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 0, 0, ... | [
"[1,0,0,0,1,0,0,1]\n2",
"[1,0,0,1,0,1]\n2"
] | [
"Each time you find a number 1, check whether or not it is K or more places away from the next one. If it's not, return false."
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().kLengthApart",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:10",
"tests_total": 104,
... | typescript | {
"raw_signature": "function kLengthApart(nums: number[], k: number): boolean {",
"container": null,
"callable": "kLengthApart",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "boolean",
"signature_source"... |
1,438 | longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit | Medium | Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray is less than or equal to limit.
Example 1:
Input: nums = [8,2,4,7], limit = 4
Output: 2
Explanation: All subarrays are:
[8] with maximum a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 2) == 3\n assert candidate(nums = [100, 101, 102, 103, 104],limit = 3) == 4\n assert candidate(nums = [4, 2, 2, 2, 4, 4, 2, 2],limit = 0) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8,... | [
"[8,2,4,7]\n4",
"[10,1,2,4,7,2]\n5",
"[4,2,2,2,4,4,2,2]\n0"
] | [
"Use a sliding window approach keeping the maximum and minimum value using a data structure like a multiset from STL in C++.",
"More specifically, use the two pointer technique, moving the right pointer as far as possible to the right until the subarray is not valid (maxValue - minValue > limit), then moving the ... | {
"canonical_parameter_names": [
"nums",
"limit"
],
"leetcode_dataset_entry_point": "Solution().longestSubarray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:13",
"tests_total": ... | typescript | {
"raw_signature": "function longestSubarray(nums: number[], limit: number): number {",
"container": null,
"callable": "longestSubarray",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "limit",
"type": "number"
}
],
"return_type": "number",
"signa... |
1,439 | find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows | Hard | You are given an m x n matrix mat that has its rows sorted in non-decreasing order and an integer k.
You are allowed to choose exactly one element from each row to form an array.
Return the k^th smallest array sum among all possible arrays.
Example 1:
Input: mat = [[1,3,11],[2,4,6]], k = 5
Output: 7
Explanation: Ch... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(mat = [[1, 10, 10], [1, 4, 5], [2, 3, 6]],k = 7) == 9\n assert candidate(mat = [[1, 2, 3], [4, 5, 6]],k = 9) == 9\n assert candidate(mat = [[1, 3, 11], [2, 4, 6]],k = 5) == 7\n assert candidate(mat = [[1, 3, 11], [2, 4, 6]],k = ... | [
"[[1,3,11],[2,4,6]]\n5",
"[[1,3,11],[2,4,6]]\n9",
"[[1,10,10],[1,4,5],[2,3,6]]\n7"
] | [
"Save all visited sums and corresponding indexes in a priority queue. Then, once you pop the smallest sum so far, you can quickly identify the next m candidates for smallest sum by incrementing each row index by 1."
] | {
"canonical_parameter_names": [
"mat",
"k"
],
"leetcode_dataset_entry_point": "Solution().kthSmallest",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:15",
"tests_total": 85,
"te... | typescript | {
"raw_signature": "function kthSmallest(mat: number[][], k: number): number {",
"container": null,
"callable": "kthSmallest",
"parameters": [
{
"name": "mat",
"type": "number[][]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": ... |
1,441 | build-an-array-with-stack-operations | Medium | You are given an integer array target and an integer n.
You have an empty stack with the two following operations:
- "Push": pushes an integer to the top of the stack.
- "Pop": removes the integer on the top of the stack.
You also have a stream of the integers in the range [1, n].
Use the two stack operations to ma... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(target = [3, 4, 5],n = 5) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push']\n assert candidate(target = [3, 4, 6],n = 7) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [... | [
"[1,3]\n3",
"[1,2,3]\n3",
"[1,2]\n4"
] | [
"Use “Push” for numbers to be kept in target array and [“Push”, “Pop”] for numbers to be discarded."
] | {
"canonical_parameter_names": [
"target",
"n"
],
"leetcode_dataset_entry_point": "Solution().buildArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:17",
"tests_total": 113,
... | typescript | {
"raw_signature": "function buildArray(target: number[], n: number): string[] {",
"container": null,
"callable": "buildArray",
"parameters": [
{
"name": "target",
"type": "number[]"
},
{
"name": "n",
"type": "number"
}
],
"return_type": "string[]",
"signature_sourc... |
1,442 | count-triplets-that-can-form-two-arrays-of-equal-xor | Medium | Given an array of integers arr.
We want to select three indices i, j and k where (0 <= i < j <= k < arr.length).
Let's define a and b as follows:
- a = arr[i] ^ arr[i + 1] ^ ... ^ arr[j - 1]
- b = arr[j] ^ arr[j + 1] ^ ... ^ arr[k]
Note that ^ denotes the bitwise-xor operation.
Return the number of triplets (i, j ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [2, 3, 4, 1, 5, 6, 7, 8, 9]) == 17\n assert candidate(arr = [5, 5, 5, 5, 5, 5]) == 19\n assert candidate(arr = [8, 12, 3, 10]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 24\n assert candidate(arr = [3... | [
"[2,3,1,6,7]",
"[1,1,1,1,1]"
] | [
"We are searching for sub-array of length ≥ 2 and we need to split it to 2 non-empty arrays so that the xor of the first array is equal to the xor of the second array. This is equivalent to searching for sub-array with xor = 0.",
"Keep the prefix xor of arr in another array, check the xor of all sub-arrays in O(n... | {
"canonical_parameter_names": [
"arr"
],
"leetcode_dataset_entry_point": "Solution().countTriplets",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:19",
"tests_total": 93,
"tests_dro... | typescript | {
"raw_signature": "function countTriplets(arr: number[]): number {",
"container": null,
"callable": "countTriplets",
"parameters": [
{
"name": "arr",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
1,444 | number-of-ways-of-cutting-a-pizza | Hard | Given a rectangular pizza represented as a rows x cols matrix containing the following characters: 'A' (an apple) and '.' (empty cell) and given the integer k. You have to cut the pizza into k pieces using k-1 cuts.
For each cut you choose the direction: vertical or horizontal, then you choose a cut position at the ce... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(pizza = ['A', 'A', 'A'],k = 3) == 1\n assert candidate(pizza = ['AA', 'AA'],k = 2) == 2\n assert candidate(pizza = ['A.A', 'A.A', 'A.A'],k = 4) == 6\n assert candidate(pizza = ['A.A', 'A.A', 'A.A'],k = 5) == 0\n assert candid... | [
"[\"A..\",\"AAA\",\"...\"]\n3",
"[\"A..\",\"AA.\",\"...\"]\n3",
"[\"A..\",\"A..\",\"...\"]\n1"
] | [
"Note that after each cut the remaining piece of pizza always has the lower right coordinate at (rows-1,cols-1).",
"Use dynamic programming approach with states (row1, col1, c) which computes the number of ways of cutting the pizza using \"c\" cuts where the current piece of pizza has upper left coordinate at (ro... | {
"canonical_parameter_names": [
"pizza",
"k"
],
"leetcode_dataset_entry_point": "Solution().ways",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:21",
"tests_total": 72,
"tests_d... | typescript | {
"raw_signature": "function ways(pizza: string[], k: number): number {",
"container": null,
"callable": "ways",
"parameters": [
{
"name": "pizza",
"type": "string[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/code... |
1,446 | consecutive-characters | Easy | The power of the string is the maximum length of a non-empty substring that contains only one unique character.
Given a string s, return the power of s.
Example 1:
Input: s = "leetcode"
Output: 2
Explanation: The substring "ee" is of length 2 with the character 'e' only.
Example 2:
Input: s = "abbcccddddeeeeedcba"... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"tourist\") == 1\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"aabbbbccc\") == 4\n assert candidate(s = \"cccccaaaa\") == 5\n assert candidate(... | [
"\"leetcode\"",
"\"abbcccddddeeeeedcba\""
] | [
"Keep an array power where power[i] is the maximum power of the i-th character.",
"The answer is max(power[i])."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().maxPower",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:23",
"tests_total": 70,
"tests_dropped": ... | typescript | {
"raw_signature": "function maxPower(s: string): number {",
"container": null,
"callable": "maxPower",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,447 | simplified-fractions | Medium | Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n. You can return the answer in any order.
Example 1:
Input: n = 2
Output: ["1/2"]
Explanation: "1/2" is the only unique fraction with a denominator less-than-or-equal-to 2.
Ex... | {
"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",
"3",
"4"
] | [
"A fraction is fully simplified if there is no integer that divides cleanly into the numerator and denominator.",
"In other words the greatest common divisor of the numerator and the denominator of a simplified fraction is 1."
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().simplifiedFractions",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:26",
"tests_total": 22,
"tests... | typescript | {
"raw_signature": "function simplifiedFractions(n: number): string[] {",
"container": null,
"callable": "simplifiedFractions",
"parameters": [
{
"name": "n",
"type": "number"
}
],
"return_type": "string[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
1,449 | form-largest-integer-with-digits-that-add-up-to-target | Hard | Given an array of integers cost and an integer target, return the maximum integer you can paint under the following rules:
- The cost of painting a digit (i + 1) is given by cost[i] (0-indexed).
- The total cost used must be equal to target.
- The integer does not have 0 digits.
Since the answer may be very large, re... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(cost = [5, 3, 7, 5, 2, 6, 8, 9, 1],target = 10) == \"9999999999\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 20) == \"99999999999999999999\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 25) == ... | [
"[4,3,2,5,6,7,2,5,5]\n9",
"[7,6,5,5,5,6,8,7,8]\n12",
"[2,4,6,2,4,6,4,4,4]\n5"
] | [
"Use dynamic programming to find the maximum digits to paint given a total cost.",
"Build the largest number possible using this DP table."
] | {
"canonical_parameter_names": [
"cost",
"target"
],
"leetcode_dataset_entry_point": "Solution().largestNumber",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:30",
"tests_total": 1... | typescript | {
"raw_signature": "function largestNumber(cost: number[], target: number): string {",
"container": null,
"callable": "largestNumber",
"parameters": [
{
"name": "cost",
"type": "number[]"
},
{
"name": "target",
"type": "number"
}
],
"return_type": "string",
"signatu... |
1,450 | number-of-students-doing-homework-at-a-given-time | Easy | Given two integer arrays startTime and endTime and given an integer queryTime.
The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].
Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime la... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(startTime = [9, 8, 7, 6],endTime = [10, 9, 8, 7],queryTime = 8) == 2\n assert candidate(startTime = [5, 5, 5, 5],endTime = [10, 10, 10, 10],queryTime = 7) == 4\n assert candidate(startTime = [9, 8, 7, 6, 5, 4, 3, 2, 1],endTime = [1... | [
"[1,2,3]\n[3,2,7]\n4",
"[4]\n[4]\n4"
] | [
"Imagine that startTime[i] and endTime[i] form an interval (i.e. [startTime[i], endTime[i]]).",
"The answer is how many times the queryTime laid in those mentioned intervals."
] | {
"canonical_parameter_names": [
"startTime",
"endTime",
"queryTime"
],
"leetcode_dataset_entry_point": "Solution().busyStudent",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:32... | typescript | {
"raw_signature": "function busyStudent(startTime: number[], endTime: number[], queryTime: number): number {",
"container": null,
"callable": "busyStudent",
"parameters": [
{
"name": "startTime",
"type": "number[]"
},
{
"name": "endTime",
"type": "number[]"
},
{
... |
1,451 | rearrange-words-in-a-sentence | Medium | Given a sentence text (A sentence is a string of space-separated words) in the following format:
- First letter is in upper case.
- Each word in text are separated by a single space.
Your task is to rearrange the words in text such that all words are rearranged in an increasing order of their lengths. If two words ha... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(text = \"A quick brown fox jumps over the lazy dog\") == \"A fox the dog over lazy quick brown jumps\"\n assert candidate(text = \"This is a simple test case\") == \"A is this test case simple\"\n assert candidate(text = \"The weat... | [
"\"Leetcode is cool\"",
"\"Keep calm and code on\"",
"\"To be or not to be\""
] | [
"Store each word and their relative position. Then, sort them by length of words in case of tie by their original order."
] | {
"canonical_parameter_names": [
"text"
],
"leetcode_dataset_entry_point": "Solution().arrangeWords",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:35",
"tests_total": 152,
"tests_dr... | typescript | {
"raw_signature": "function arrangeWords(text: string): string {",
"container": null,
"callable": "arrangeWords",
"parameters": [
{
"name": "text",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,452 | people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list | Medium | Given the array favoriteCompanies where favoriteCompanies[i] is the list of favorites companies for the ith person (indexed from 0).
Return the indices of people whose list of favorite companies is not a subset of any other list of favorites companies. You must return the indices in increasing order.
Example 1:
Inpu... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(favoriteCompanies = [['leetcode'], ['google'], ['facebook'], ['amazon']]) == [0, 1, 2, 3]\n assert candidate(favoriteCompanies = [['apple'], ['apple', 'google'], ['google', 'facebook'], ['apple', 'facebook', 'google']]) == [3]\n as... | [
"[[\"leetcode\",\"google\",\"facebook\"],[\"google\",\"microsoft\"],[\"google\",\"facebook\"],[\"google\"],[\"amazon\"]]",
"[[\"leetcode\",\"google\",\"facebook\"],[\"leetcode\",\"amazon\"],[\"facebook\",\"google\"]]",
"[[\"leetcode\"],[\"google\"],[\"facebook\"],[\"amazon\"]]"
] | [
"Use hashing to convert company names in numbers and then for each list check if this is a subset of any other list.",
"In order to check if a list is a subset of another list, use two pointers technique to get a linear solution for this task. The total complexity will be O(n^2 * m) where n is the number of lists... | {
"canonical_parameter_names": [
"favoriteCompanies"
],
"leetcode_dataset_entry_point": "Solution().peopleIndexes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:37",
"tests_total": 79... | typescript | {
"raw_signature": "function peopleIndexes(favoriteCompanies: string[][]): number[] {",
"container": null,
"callable": "peopleIndexes",
"parameters": [
{
"name": "favoriteCompanies",
"type": "string[][]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"ty... |
1,453 | maximum-number-of-darts-inside-of-a-circular-dartboard | Hard | Alice is throwing n darts on a very large wall. You are given an array darts where darts[i] = [x_i, y_i] is the position of the i^th dart that Alice threw on the wall.
Bob knows the positions of the n darts on the wall. He wants to place a dartboard of radius r on the wall so that the maximum number of darts that Alic... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(darts = [[100, 100], [-100, -100], [0, 0]],r = 150) == 3\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3]],r = 1) == 3\n assert candidate(darts = [[-3, 0], [3, 0], [2, 6], [5, 4], [0, 9], [7, 8]],r = 5) == 5\n assert c... | [
"[[-2,0],[2,0],[0,2],[0,-2]]\n2",
"[[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]]\n5"
] | [
"If there is an optimal solution, you can always move the circle so that two points lie on the boundary of the circle.",
"When the radius is fixed, you can find either 0 or 1 or 2 circles that pass two given points at the same time.",
"Loop for each pair of points and find the center of the circle, after that c... | {
"canonical_parameter_names": [
"darts",
"r"
],
"leetcode_dataset_entry_point": "Solution().numPoints",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:39",
"tests_total": 130,
"t... | typescript | {
"raw_signature": "function numPoints(darts: number[][], r: number): number {",
"container": null,
"callable": "numPoints",
"parameters": [
{
"name": "darts",
"type": "number[][]"
},
{
"name": "r",
"type": "number"
}
],
"return_type": "number",
"signature_source": ... |
1,455 | check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence | Easy | Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence.
Return the index of the word in sentence (1-indexed) where searchWord is a prefix of this word. If searchWord is a prefix of more than one word, return the index of the f... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(sentence = \"a ab abc abd\",searchWord = \"a\") == 1\n assert candidate(sentence = \"abcde fghij klmno\",searchWord = \"mnop\") == -1\n assert candidate(sentence = \"find prefix quickly\",searchWord = \"qui\") == 3\n assert cand... | [
"\"i love eating burger\"\n\"burg\"",
"\"this problem is an easy problem\"\n\"pro\"",
"\"i am tired\"\n\"you\""
] | [
"First extract the words of the sentence.",
"Check for each word if searchWord occurs at index 0, if so return the index of this word (1-indexed)",
"If searchWord doesn't exist as a prefix of any word return the default value (-1)."
] | {
"canonical_parameter_names": [
"sentence",
"searchWord"
],
"leetcode_dataset_entry_point": "Solution().isPrefixOfWord",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:42",
"tests_... | typescript | {
"raw_signature": "function isPrefixOfWord(sentence: string, searchWord: string): number {",
"container": null,
"callable": "isPrefixOfWord",
"parameters": [
{
"name": "sentence",
"type": "string"
},
{
"name": "searchWord",
"type": "string"
}
],
"return_type": "numbe... |
1,456 | maximum-number-of-vowels-in-a-substring-of-given-length | Medium | Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.
Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.
Example 1:
Input: s = "abciiidef", k = 3
Output: 3
Explanation: The substring "iii" contains 3 vowel letters.
Example 2:
Input: s = "aeiou", k... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"aooiiieeec\",k = 6) == 6\n assert candidate(s = \"a\",k = 1) == 1\n assert candidate(s = \"happy\",k = 2) == 1\n assert candidate(s = \"rhythms\",k = 5) == 0\n assert candidate(s = \"fluffy\",k = 2) == 1\n assert can... | [
"\"abciiidef\"\n3",
"\"aeiou\"\n2",
"\"leetcode\"\n3"
] | [
"Keep a window of size k and maintain the number of vowels in it.",
"Keep moving the window and update the number of vowels while moving. Answer is max number of vowels of any window."
] | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxVowels",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:44",
"tests_total": 80,
"tests_... | typescript | {
"raw_signature": "function maxVowels(s: string, k: number): number {",
"container": null,
"callable": "maxVowels",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSn... |
1,458 | max-dot-product-of-two-subsequences | Hard | Given two arrays nums1 and nums2.
Return the maximum dot product between non-empty subsequences of nums1 and nums2 with the same length.
A subsequence of an array is a new array which is formed from the original array by deleting some (can be none) of the characters without disturbing the relative positions of the re... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1]) == 2\n assert candidate(nums1 = [2, 1, -2, 5],nums2 = [3, 0, -6]) == 18\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 46\n assert candidate(nums1 = [1, 3, -5, 4],nu... | [
"[2,1,-2,5]\n[3,0,-6]",
"[3,-2]\n[2,-6,7]",
"[-1,-1]\n[1,1]"
] | [
"Use dynamic programming, define DP[i][j] as the maximum dot product of two subsequences starting in the position i of nums1 and position j of nums2."
] | {
"canonical_parameter_names": [
"nums1",
"nums2"
],
"leetcode_dataset_entry_point": "Solution().maxDotProduct",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:46",
"tests_total": 1... | typescript | {
"raw_signature": "function maxDotProduct(nums1: number[], nums2: number[]): number {",
"container": null,
"callable": "maxDotProduct",
"parameters": [
{
"name": "nums1",
"type": "number[]"
},
{
"name": "nums2",
"type": "number[]"
}
],
"return_type": "number",
"sig... |
1,460 | make-two-arrays-equal-by-reversing-subarrays | Easy | You are given two integer arrays of equal length target and arr. In one step, you can select any non-empty subarray of arr and reverse it. You are allowed to make any number of steps.
Return true if you can make arr equal to target or false otherwise.
Example 1:
Input: target = [1,2,3,4], arr = [2,4,1,3]
Output: tru... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(target = [4, 3, 2, 1],arr = [1, 2, 3, 4]) == True\n assert candidate(target = [5, 6, 7, 8],arr = [8, 7, 6, 5]) == True\n assert candidate(target = [1, 1, 1, 1],arr = [1, 1, 1, 1]) == True\n assert candidate(target = [1, 3, 5, 7]... | [
"[1,2,3,4]\n[2,4,1,3]",
"[7]\n[7]",
"[3,7,9]\n[3,7,11]"
] | [
"Each element of target should have a corresponding element in arr, and if it doesn't have a corresponding element, return false.",
"To solve it easiely you can sort the two arrays and check if they are equal."
] | {
"canonical_parameter_names": [
"target",
"arr"
],
"leetcode_dataset_entry_point": "Solution().canBeEqual",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:48",
"tests_total": 122,
... | typescript | {
"raw_signature": "function canBeEqual(target: number[], arr: number[]): boolean {",
"container": null,
"callable": "canBeEqual",
"parameters": [
{
"name": "target",
"type": "number[]"
},
{
"name": "arr",
"type": "number[]"
}
],
"return_type": "boolean",
"signature... |
1,461 | check-if-a-string-contains-all-binary-codes-of-size-k | Medium | Given a binary string s and an integer k, return true if every binary code of length k is a substring of s. Otherwise, return false.
Example 1:
Input: s = "00110110", k = 2
Output: true
Explanation: The binary codes of length 2 are "00", "01", "10" and "11". They can be all found as substrings at indices 0, 1, 3 and ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"1010101010\",k = 5) == False\n assert candidate(s = \"1010101010\",k = 3) == False\n assert candidate(s = \"0000000\",k = 3) == False\n assert candidate(s = \"00110110\",k = 2) == True\n assert candidate(s = \"00000000\... | [
"\"00110110\"\n2",
"\"0110\"\n1",
"\"0110\"\n2"
] | [
"We need only to check all sub-strings of length k.",
"The number of distinct sub-strings should be exactly 2^k."
] | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().hasAllCodes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:20:51",
"tests_total": 102,
"tes... | typescript | {
"raw_signature": "function hasAllCodes(s: string, k: number): boolean {",
"container": null,
"callable": "hasAllCodes",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "boolean",
"signature_source": "leetcode/... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.