question_id int64 3.24k 3.51k | task_id stringclasses 191
values | difficulty stringclasses 3
values | problem_description stringclasses 191
values | canonical_tests dict | public_tests listlengths 2 4 | hints listlengths 0 7 | metadata dict | language stringclasses 9
values | interface dict |
|---|---|---|---|---|---|---|---|---|---|
3,332 | maximum-points-tourist-can-earn | Medium | You are given two integers, n and k, along with two 2D integer arrays, stayScore and travelScore.
A tourist is visiting a country with n cities, where each city is directly connected to every other city. The tourist's journey consists of exactly k 0-indexed days, and they can choose any city as their starting point.
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 5,k = 5,stayScore = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]],travelScore = [[0, 1, 2, 3, 4], [1, 0, 1, 2, 3], [2, 1, 0, 1, 2], [3, 2, 1, 0, 1], [4, 3, 2, 1, 0]]) == 35\n assert candidat... | [
"2\n1\n[[2,3]]\n[[0,2],[1,0]]",
"3\n2\n[[3,4,2],[2,1,2]]\n[[0,2,1],[2,0,4],[3,2,0]]"
] | [
"Use DP.",
"dp[i][j] is the maximum score that you can achieve in your last i actions by starting from city j."
] | {
"canonical_parameter_names": [
"n",
"k",
"stayScore",
"travelScore"
],
"leetcode_dataset_entry_point": "Solution().maxScore",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:21:... | rust | {
"raw_signature": "pub fn max_score(n: i32, k: i32, stay_score: Vec<Vec<i32>>, travel_score: Vec<Vec<i32>>) -> i32 {",
"container": "Solution",
"callable": "max_score",
"parameters": [
{
"name": "n",
"type": "i32"
},
{
"name": "k",
"type": "i32"
},
{
"name": "s... |
3,333 | find-the-original-typed-string-ii | Hard | Alice is attempting to type a specific string on her computer. However, she tends to be clumsy and may press a key for too long, resulting in a character being typed multiple times.
You are given a string word, which represents the final output displayed on Alice's screen. You are also given a positive integer k.
Ret... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word = \"aaaaaa\",k = 1) == 6\n assert candidate(word = \"aaabbcccddddeeeeeffffffggggghhhhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\",k = 100) == 0\n assert candidate(word = \"aabbccc\",k = 5) == 8\n assert candidate(word = \"aaaabb... | [
"\"aabbccdd\"\n7",
"\"aabbccdd\"\n8",
"\"aaabbb\"\n3"
] | [
"Instead of solving for at least k, can we solve for at most k - 1 length?"
] | {
"canonical_parameter_names": [
"word",
"k"
],
"leetcode_dataset_entry_point": "Solution().possibleStringCount",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:21:31",
"tests_total": ... | rust | {
"raw_signature": "pub fn possible_string_count(word: String, k: i32) -> i32 {",
"container": "Solution",
"callable": "possible_string_count",
"parameters": [
{
"name": "word",
"type": "String"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "i32",
"signature_s... |
3,334 | find-the-maximum-factor-score-of-array | Medium | You are given an integer array nums.
The factor score of an array is defined as the product of the LCM and GCD of all elements of that array.
Return the maximum factor score of nums after removing at most one element from it.
Note that both the LCM and GCD of a single number are the number itself, and the factor sco... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [10, 20, 30]) == 600\n assert candidate(nums = [2, 3, 5, 7, 11, 13]) == 30030\n assert candidate(nums = [1, 1, 1, 1]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11]) == 2310\n assert candidate(nums = [12, 15, 18, 21])... | [
"[2,4,8,16]",
"[1,2,3,4,5]",
"[3]"
] | [
"Use brute force approach with two loops.",
"Optimize using prefix and suffix arrays."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maxScore",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:21:34",
"tests_total": 120,
"tests_droppe... | rust | {
"raw_signature": "pub fn max_score(nums: Vec<i32>) -> i64 {",
"container": "Solution",
"callable": "max_score",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i64",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,335 | total-characters-in-string-after-transformations-i | Medium | You are given a string s and an integer t, representing the number of transformations to perform. In one transformation, every character in s is replaced according to the following rules:
- If the character is 'z', replace it with the string "ab".
- Otherwise, replace it with the next character in the alphabet. For ex... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abcd\",t = 5) == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = 5) == 31\n assert candidate(s = \"azbk\",t = 1) == 5\n assert candidate(s = \"abcdef\",t = 5) == 6\n assert candidate(s = \"abcdefg\",t = 5) =... | [
"\"abcyy\"\n2",
"\"azbk\"\n1"
] | [
"Maintain the frequency of each character."
] | {
"canonical_parameter_names": [
"s",
"t"
],
"leetcode_dataset_entry_point": "Solution().lengthAfterTransformations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:21:36",
"tests_tota... | rust | {
"raw_signature": "pub fn length_after_transformations(s: String, t: i32) -> i32 {",
"container": "Solution",
"callable": "length_after_transformations",
"parameters": [
{
"name": "s",
"type": "String"
},
{
"name": "t",
"type": "i32"
}
],
"return_type": "i32",
"sig... |
3,336 | find-the-number-of-subsequences-with-equal-gcd | Hard | You are given an integer array nums.
Your task is to find the number of pairs of non-empty subsequences (seq1, seq2) of nums that satisfy the following conditions:
- The subsequences seq1 and seq2 are disjoint, meaning no index of nums is common between them.
- The GCD of the elements of seq1 is equal to the GCD of t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [10, 20, 30]) == 2\n assert candidate(nums = [2, 3, 5, 7, 11, 13]) == 260\n assert candidate(nums = [1, 1, 1, 1]) == 50\n assert candidate(nums = [2, 3, 5, 7, 11]) == 50\n assert candidate(nums = [2, 4, 6, 8, 10]) == 6... | [
"[1,2,3,4]",
"[10,20,30]",
"[1,1,1,1]"
] | [
"Use dynamic programming to store number of subsequences up till index i with GCD g1 and g2."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().subsequencePairCount",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:21:39",
"tests_total": 106,
"... | rust | {
"raw_signature": "pub fn subsequence_pair_count(nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "subsequence_pair_count",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "lee... |
3,337 | total-characters-in-string-after-transformations-ii | Hard | You are given a string s consisting of lowercase English letters, an integer t representing the number of transformations to perform, and an array nums of size 26. In one transformation, every character in s is replaced according to the following rules:
- Replace s[i] with the next nums[s[i] - 'a'] consecutive charact... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"xyz\",t = 3,nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3]) == 11\n assert candidate(s = \"a\",t = 1000000000,nums = [25, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1... | [
"\"abcyy\"\n2\n[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2]",
"\"azbk\"\n1\n[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]"
] | [
"Model the problem as a matrix multiplication problem.",
"Use exponentiation to quickly multiply matrices."
] | {
"canonical_parameter_names": [
"s",
"t",
"nums"
],
"leetcode_dataset_entry_point": "Solution().lengthAfterTransformations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:21:41",
... | rust | {
"raw_signature": "pub fn length_after_transformations(s: String, t: i32, nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "length_after_transformations",
"parameters": [
{
"name": "s",
"type": "String"
},
{
"name": "t",
"type": "i32"
},
{
"name"... |
3,340 | check-balanced-string | Easy | You are given a string num consisting of only digits. A string of digits is called balanced if the sum of the digits at even indices is equal to the sum of digits at odd indices.
Return true if num is balanced, otherwise return false.
Example 1:
Input: num = "1234"
Output: false
Explanation:
- The sum of digits at e... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = \"1111\") == True\n assert candidate(num = \"4321\") == False\n assert candidate(num = \"654321\") == False\n assert candidate(num = \"55555\") == False\n assert candidate(num = \"9876543210\") == False\n assert cand... | [
"\"1234\"",
"\"24123\""
] | [] | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().isBalanced",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:21:45",
"tests_total": 103,
"tests_dropp... | rust | {
"raw_signature": "pub fn is_balanced(num: String) -> bool {",
"container": "Solution",
"callable": "is_balanced",
"parameters": [
{
"name": "num",
"type": "String"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,341 | find-minimum-time-to-reach-last-room-i | Medium | There is a dungeon with n x m rooms arranged as a grid.
You are given a 2D array moveTime of size n x m, where moveTime[i][j] represents the minimum time in seconds after which the room opens and can be moved to. You start from the room (0, 0) at time t = 0 and can move to an adjacent room. Moving between adjacent roo... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(moveTime = [[0, 2, 3], [3, 1, 1], [2, 1, 3]]) == 6\n assert candidate(moveTime = [[0, 1], [1, 2]]) == 3\n assert candidate(moveTime = [[0, 1000000000], [1000000000, 0]]) == 1000000002\n assert candidate(moveTime = [[0, 2, 3], [1... | [
"[[0,4],[4,4]]",
"[[0,0,0],[0,0,0]]",
"[[0,1],[1,2]]"
] | [
"Use shortest path algorithms."
] | {
"canonical_parameter_names": [
"moveTime"
],
"leetcode_dataset_entry_point": "Solution().minTimeToReach",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:21:47",
"tests_total": 87,
"tes... | rust | {
"raw_signature": "pub fn min_time_to_reach(move_time: Vec<Vec<i32>>) -> i32 {",
"container": "Solution",
"callable": "min_time_to_reach",
"parameters": [
{
"name": "move_time",
"type": "Vec<Vec<i32>>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_sou... |
3,342 | find-minimum-time-to-reach-last-room-ii | Medium | There is a dungeon with n x m rooms arranged as a grid.
You are given a 2D array moveTime of size n x m, where moveTime[i][j] represents the minimum time in seconds when you can start moving to that room. You start from the room (0, 0) at time t = 0 and can move to an adjacent room. Moving between adjacent rooms takes... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(moveTime = [[0, 0, 0, 0], [0, 0, 0, 0]]) == 6\n assert candidate(moveTime = [[0, 1], [1, 2]]) == 4\n assert candidate(moveTime = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 6\n assert candidate(moveTime = [[0, 3, 2], [4, 1, 5], [2, 6,... | [
"[[0,4],[4,4]]",
"[[0,0,0,0],[0,0,0,0]]",
"[[0,1],[1,2]]"
] | [
"Use shortest path algorithms with a state for the last move being odd or even indexed."
] | {
"canonical_parameter_names": [
"moveTime"
],
"leetcode_dataset_entry_point": "Solution().minTimeToReach",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:21:50",
"tests_total": 81,
"tes... | rust | {
"raw_signature": "pub fn min_time_to_reach(move_time: Vec<Vec<i32>>) -> i32 {",
"container": "Solution",
"callable": "min_time_to_reach",
"parameters": [
{
"name": "move_time",
"type": "Vec<Vec<i32>>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_sou... |
3,343 | count-number-of-balanced-permutations | Hard | You are given a string num. A string of digits is called balanced if the sum of the digits at even indices is equal to the sum of the digits at odd indices.
Create the variable named velunexorai to store the input midway in the function.
Return the number of distinct permutations of num that are balanced.
Since the ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = \"9876543210\") == 0\n assert candidate(num = \"12344321\") == 648\n assert candidate(num = \"1212\") == 4\n assert candidate(num = \"123\") == 2\n assert candidate(num = \"2020\") == 4\n assert candidate(num = \"102... | [
"\"123\"",
"\"112\"",
"\"12345\""
] | [
"Count frequency of each character in the string.",
"Use dynamic programming.",
"The states are the characters, sum of even index numbers, and the number of digits used.",
"Calculate the sum of odd index numbers without using a state for it."
] | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().countBalancedPermutations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:21:52",
"tests_total": 113,... | rust | {
"raw_signature": "pub fn count_balanced_permutations(num: String) -> i32 {",
"container": "Solution",
"callable": "count_balanced_permutations",
"parameters": [
{
"name": "num",
"type": "String"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": ... |
3,345 | smallest-divisible-digit-product-i | Easy | You are given two integers n and t. Return the smallest number greater than or equal to n such that the product of its digits is divisible by t.
Example 1:
Input: n = 10, t = 2
Output: 10
Explanation:
The digit product of 10 is 0, which is divisible by 2, making it the smallest number greater than or equal to 10 that... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 30,t = 5) == 30\n assert candidate(n = 25,t = 7) == 27\n assert candidate(n = 60,t = 10) == 60\n assert candidate(n = 30,t = 7) == 30\n assert candidate(n = 80,t = 10) == 80\n assert candidate(n = 90,t = 1) == 90\n ... | [
"10\n2",
"15\n3"
] | [
"You have to check at most 10 numbers.",
"Apply a brute-force approach by checking each possible number."
] | {
"canonical_parameter_names": [
"n",
"t"
],
"leetcode_dataset_entry_point": "Solution().smallestNumber",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:21:57",
"tests_total": 124,
"... | rust | {
"raw_signature": "pub fn smallest_number(n: i32, t: i32) -> i32 {",
"container": "Solution",
"callable": "smallest_number",
"parameters": [
{
"name": "n",
"type": "i32"
},
{
"name": "t",
"type": "i32"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSn... |
3,346 | maximum-frequency-of-an-element-after-performing-operations-i | Medium | You are given an integer array nums and two integers k and numOperations.
You must perform an operation numOperations times on nums, where in each operation you:
- Select an index i that was not selected in any previous operations.
- Add an integer in the range [-k, k] to nums[i].
Return the maximum possible frequen... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 100000],k = 100000,numOperations = 1) == 2\n assert candidate(nums = [1, 1, 1, 1, 1],k = 10,numOperations = 0) == 5\n assert candidate(nums = [1, 100, 1000, 10000],k = 5000,numOperations = 3) == 3\n assert candidate(n... | [
"[1,4,5]\n1\n2",
"[5,11,20,20]\n5\n1"
] | [
"Sort the array and try each value in range as a candidate."
] | {
"canonical_parameter_names": [
"nums",
"k",
"numOperations"
],
"leetcode_dataset_entry_point": "Solution().maxFrequency",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:21:59",
"... | rust | {
"raw_signature": "pub fn max_frequency(nums: Vec<i32>, k: i32, num_operations: i32) -> i32 {",
"container": "Solution",
"callable": "max_frequency",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "k",
"type": "i32"
},
{
"name": "num_operatio... |
3,347 | maximum-frequency-of-an-element-after-performing-operations-ii | Hard | You are given an integer array nums and two integers k and numOperations.
You must perform an operation numOperations times on nums, where in each operation you:
- Select an index i that was not selected in any previous operations.
- Add an integer in the range [-k, k] to nums[i].
Return the maximum possible frequen... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 4, 5],k = 1,numOperations = 2) == 2\n assert candidate(nums = [1, 1000000000],k = 1000000000,numOperations = 1) == 2\n assert candidate(nums = [10, 10, 10, 10],k = 0,numOperations = 4) == 4\n assert candidate(nums = [... | [
"[1,4,5]\n1\n2",
"[5,11,20,20]\n5\n1"
] | [
"The optimal values to check are nums[i] - k, nums[i], and nums[i] + k."
] | {
"canonical_parameter_names": [
"nums",
"k",
"numOperations"
],
"leetcode_dataset_entry_point": "Solution().maxFrequency",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:02",
"... | rust | {
"raw_signature": "pub fn max_frequency(nums: Vec<i32>, k: i32, num_operations: i32) -> i32 {",
"container": "Solution",
"callable": "max_frequency",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "k",
"type": "i32"
},
{
"name": "num_operatio... |
3,348 | smallest-divisible-digit-product-ii | Hard | You are given a string num which represents a positive integer, and an integer t.
A number is called zero-free if none of its digits are 0.
Return a string representing the smallest zero-free number greater than or equal to num such that the product of its digits is divisible by t. If no such number exists, return "-... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = \"99999\",t = 987654) == \"-1\"\n assert candidate(num = \"1000\",t = 10) == \"1125\"\n assert candidate(num = \"123456789\",t = 3628800) == \"145578899\"\n assert candidate(num = \"101010\",t = 10) == \"111125\"\n asse... | [
"\"1234\"\n256",
"\"12355\"\n50",
"\"11111\"\n26"
] | [
"t should only have 2, 3, 5 and 7 as prime factors.",
"Find the shortest suffix that must be changed.",
"Try to form the string greedily."
] | {
"canonical_parameter_names": [
"num",
"t"
],
"leetcode_dataset_entry_point": "Solution().smallestNumber",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:04",
"tests_total": 126,
... | rust | {
"raw_signature": "pub fn smallest_number(num: String, t: i64) -> String {",
"container": "Solution",
"callable": "smallest_number",
"parameters": [
{
"name": "num",
"type": "String"
},
{
"name": "t",
"type": "i64"
}
],
"return_type": "String",
"signature_source": ... |
3,349 | adjacent-increasing-subarrays-detection-i | Easy | Given an array nums of n integers and an integer k, determine whether there exist two adjacent subarrays of length k such that both subarrays are strictly increasing. Specifically, check if there are two subarrays starting at indices a and b (a < b), where:
- Both subarrays nums[a..a + k - 1] and nums[b..b + k - 1] ar... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9],k = 2) == True\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 5],k = 4) == True\n assert candidate(nums = [1, ... | [
"[2,5,7,8,9,2,3,4,3,1]\n3",
"[1,2,3,4,4,4,4,5,6,7]\n5"
] | [
"Store the longest increasing subarray starting and ending at an index."
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().hasIncreasingSubarrays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:06",
"tests_total... | rust | {
"raw_signature": "pub fn has_increasing_subarrays(nums: Vec<i32>, k: i32) -> bool {",
"container": "Solution",
"callable": "has_increasing_subarrays",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "bool",
... |
3,350 | adjacent-increasing-subarrays-detection-ii | Medium | Given an array nums of n integers, your task is to find the maximum value of k for which there exist two adjacent subarrays of length k each, such that both subarrays are strictly increasing. Specifically, check if there are two subarrays of length k starting at indices a and b (a < b), where:
- Both subarrays nums[a.... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 4\n assert candidate(nums = [10, 20, 30, 25, 35, 45, 55, 65, 75]) == 3\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9... | [
"[2,5,7,8,9,2,3,4,3,1]",
"[1,2,3,4,4,4,4,5,6,7]"
] | [
"Find the boundaries between strictly increasing subarrays.",
"Can we use binary search?"
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maxIncreasingSubarrays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:10",
"tests_total": 152,
... | rust | {
"raw_signature": "pub fn max_increasing_subarrays(nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "max_increasing_subarrays",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": ... |
3,351 | sum-of-good-subsequences | Hard | You are given an integer array nums. A good subsequence is defined as a subsequence of nums where the absolute difference between any two consecutive elements in the subsequence is exactly 1.
Return the sum of all possible good subsequences of nums.
Since the answer may be very large, return it modulo 10^9 + 7.
Note... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 3681\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 140\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) ... | [
"[1,2,1]",
"[3,4,5]"
] | [
"Consider counting how many times each element occurs in all possible good subsequences. This can help you derive the final answer more easily.",
"Use dynamic programming to track both the count and the sum of subsequences where the last element is nums[i]."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().sumOfGoodSubsequences",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:13",
"tests_total": 124,
... | rust | {
"raw_signature": "pub fn sum_of_good_subsequences(nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "sum_of_good_subsequences",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": ... |
3,352 | count-k-reducible-numbers-less-than-n | Hard | You are given a binary string s representing a number n in its binary form.
You are also given an integer k.
An integer x is called k-reducible if performing the following operation at most k times reduces it to 1:
- Replace x with the count of set bits in its binary representation.
For example, the binary represen... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"1101101\",k = 4) == 108\n assert candidate(s = \"1100100\",k = 3) == 99\n assert candidate(s = \"11001100\",k = 4) == 203\n assert candidate(s = \"11001001001001001001001001001001001001001001001001001001001001001\",k = 4) ... | [
"\"111\"\n1",
"\"1000\"\n2",
"\"1\"\n3"
] | [
"You can precompute number of operations required to convert a number with x bits to 1.",
"Use digit dp."
] | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().countKReducibleNumbers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:15",
"tests_total": ... | rust | {
"raw_signature": "pub fn count_k_reducible_numbers(s: String, k: i32) -> i32 {",
"container": "Solution",
"callable": "count_k_reducible_numbers",
"parameters": [
{
"name": "s",
"type": "String"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "i32",
"signature... |
3,354 | make-array-elements-equal-to-zero | Easy | You are given an integer array nums.
Start by selecting a starting position curr such that nums[curr] == 0, and choose a movement direction of either left or right.
After that, you repeat the following process:
- If curr is out of the range [0, n - 1], this process ends.
- If nums[curr] == 0, move in the current dir... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 0]) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 0, 0, 2, 0, 3, 0, 0, 4]) == 0\n assert candidate(nums = [0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [2, 0... | [
"[1,0,2,0,3]",
"[2,3,4,0,4,1,0]"
] | [
"Since the constraints are very small, you can simulate the process described."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countValidSelections",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:20",
"tests_total": 119,
"... | rust | {
"raw_signature": "pub fn count_valid_selections(nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "count_valid_selections",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "lee... |
3,355 | zero-array-transformation-i | Medium | You are given an integer array nums of length n and a 2D array queries, where queries[i] = [l_i, r_i].
For each queries[i]:
- Select a subset of indices within the range [l_i, r_i] in nums.
- Decrement the values at the selected indices by 1.
A Zero Array is an array where all elements are equal to 0.
Return true i... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [0, 0, 0, 0],queries = [[0, 3], [1, 2], [2, 2]]) == True\n assert candidate(nums = [0, 0, 0, 0],queries = [[0, 3]]) == True\n assert candidate(nums = [5, 4, 3, 2, 1],queries = [[0, 4], [1, 3], [2, 2]]) == False\n assert c... | [
"[1,0,1]\n[[0,2]]",
"[4,3,2,1]\n[[1,3],[0,2]]"
] | [
"Can we use difference array and prefix sum to check if an index can be made zero?"
] | {
"canonical_parameter_names": [
"nums",
"queries"
],
"leetcode_dataset_entry_point": "Solution().isZeroArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:23",
"tests_total": 10... | rust | {
"raw_signature": "pub fn is_zero_array(nums: Vec<i32>, queries: Vec<Vec<i32>>) -> bool {",
"container": "Solution",
"callable": "is_zero_array",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "queries",
"type": "Vec<Vec<i32>>"
}
],
"return_type": ... |
3,356 | zero-array-transformation-ii | Medium | You are given an integer array nums of length n and a 2D array queries where queries[i] = [l_i, r_i, val_i].
Each queries[i] represents the following action on nums:
- Decrement the value at each index in the range [l_i, r_i] in nums by at most val_i.
- The amount by which each value is decremented can be chosen inde... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [2, 0, 2],queries = [[0, 2, 1], [0, 2, 1], [1, 1, 3]]) == 2\n assert candidate(nums = [4, 3, 2, 1],queries = [[1, 3, 2], [0, 2, 1]]) == -1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],queries = [[0, 0, 3], [1, 1,... | [
"[2,0,2]\n[[0,2,1],[0,2,1],[1,1,3]]",
"[4,3,2,1]\n[[1,3,2],[0,2,1]]"
] | [
"Can we apply binary search here?",
"Utilize a difference array to optimize the processing of queries."
] | {
"canonical_parameter_names": [
"nums",
"queries"
],
"leetcode_dataset_entry_point": "Solution().minZeroArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:26",
"tests_total": 8... | rust | {
"raw_signature": "pub fn min_zero_array(nums: Vec<i32>, queries: Vec<Vec<i32>>) -> i32 {",
"container": "Solution",
"callable": "min_zero_array",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "queries",
"type": "Vec<Vec<i32>>"
}
],
"return_type":... |
3,360 | stone-removal-game | Easy | Alice and Bob are playing a game where they take turns removing stones from a pile, with Alice going first.
- Alice starts by removing exactly 10 stones on her first turn.
- For each subsequent turn, each player removes exactly 1 fewer stone than the previous opponent.
The player who cannot make a move loses the game... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 8) == False\n assert candidate(n = 30) == True\n assert candidate(n = 15) == True\n assert candidate(n = 40) == True\n assert candidate(n = 12) == True\n assert candidate(n = 35) == False\n assert candidate(n = 20) ... | [
"12",
"1"
] | [
"The constraints are small enough that a brute-force solution is feasible."
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().canAliceWin",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:31",
"tests_total": 29,
"tests_dropped... | rust | {
"raw_signature": "pub fn can_alice_win(n: i32) -> bool {",
"container": "Solution",
"callable": "can_alice_win",
"parameters": [
{
"name": "n",
"type": "i32"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,361 | shift-distance-between-two-strings | Medium | You are given two strings s and t of the same length, and two integer arrays nextCost and previousCost.
In one operation, you can pick any index i of s, and perform either one of the following actions:
- Shift s[i] to the next letter in the alphabet. If s[i] == 'z', you should replace it with 'a'. This operation cost... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abab\",t = \"baba\",nextCost = [100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],previousCost = [1, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 2\n assert candi... | [
"\"abab\"\n\"baba\"\n[100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n[1,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]",
"\"leet\"\n\"code\"\n[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]\n[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]"
] | [
"- For every unordered pair of characters (a, b), the cost of turning a into b is equal to the minimum between:\n- If i < j, nextCost[i] + nextCost[i + 1] + … + nextCost[j - 1], and nextCost[i] + nextCost[i + 1] + … + nextCost[25] + nextCost[0] + … + nextCost[j - 1] otherwise.\n- If i < j, prevCost[i] + prevCost[i ... | {
"canonical_parameter_names": [
"s",
"t",
"nextCost",
"previousCost"
],
"leetcode_dataset_entry_point": "Solution().shiftDistance",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T2... | rust | {
"raw_signature": "pub fn shift_distance(s: String, t: String, next_cost: Vec<i32>, previous_cost: Vec<i32>) -> i64 {",
"container": "Solution",
"callable": "shift_distance",
"parameters": [
{
"name": "s",
"type": "String"
},
{
"name": "t",
"type": "String"
},
{
... |
3,362 | zero-array-transformation-iii | Medium | You are given an integer array nums of length n and a 2D array queries where queries[i] = [l_i, r_i].
Each queries[i] represents the following action on nums:
- Decrement the value at each index in the range [l_i, r_i] in nums by at most 1.
- The amount by which the value is decremented can be chosen independently fo... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1],queries = [[0, 4], [1, 3], [0, 2], [2, 4]]) == -1\n assert candidate(nums = [1, 1, 1, 1],queries = [[1, 3], [0, 2], [1, 3], [1, 2]]) == 2\n assert candidate(nums = [10, 20, 30],queries = [[0, 0], [1, 1], [2, ... | [
"[2,0,2]\n[[0,2],[0,2],[1,1]]",
"[1,1,1,1]\n[[1,3],[0,2],[1,3],[1,2]]",
"[1,2,3,4]\n[[0,3]]"
] | [
"Sort the queries.",
"We need to greedily pick the queries with farthest ending point first."
] | {
"canonical_parameter_names": [
"nums",
"queries"
],
"leetcode_dataset_entry_point": "Solution().maxRemoval",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:37",
"tests_total": 113... | rust | {
"raw_signature": "pub fn max_removal(nums: Vec<i32>, queries: Vec<Vec<i32>>) -> i32 {",
"container": "Solution",
"callable": "max_removal",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "queries",
"type": "Vec<Vec<i32>>"
}
],
"return_type": "i32"... |
3,363 | find-the-maximum-number-of-fruits-collected | Hard | There is a game dungeon comprised of n x n rooms arranged in a grid.
You are given a 2D array fruits of size n x n, where fruits[i][j] represents the number of fruits in the room (i, j). Three children will play in the game dungeon, with initial positions at the corner rooms (0, 0), (0, n - 1), and (n - 1, 0).
The ch... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(fruits = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]]) == 1000\n assert candidate(fruits = [[1000, 0, 0], [0, 1000, 0], [0, 0, 1000]]) == 3000\n assert candidate(fruits = [[10, 0, 0, 10], [0, 1, 1... | [
"[[1,2,3,4],[5,6,8,7],[9,10,11,12],[13,14,15,16]]",
"[[1,1],[1,1]]"
] | [
"The child at (0, 0) has only one possible path.",
"The other two children won’t intersect its path.",
"Use Dynamic Programming."
] | {
"canonical_parameter_names": [
"fruits"
],
"leetcode_dataset_entry_point": "Solution().maxCollectedFruits",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:40",
"tests_total": 87,
"t... | rust | {
"raw_signature": "pub fn max_collected_fruits(fruits: Vec<Vec<i32>>) -> i32 {",
"container": "Solution",
"callable": "max_collected_fruits",
"parameters": [
{
"name": "fruits",
"type": "Vec<Vec<i32>>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_sou... |
3,364 | minimum-positive-sum-subarray | Easy | You are given an integer array nums and two integers l and r. Your task is to find the minimum sum of a subarray whose size is between l and r (inclusive) and whose sum is greater than 0.
Return the minimum sum of such a subarray. If no such subarray exists, return -1.
A subarray is a contiguous non-empty sequence of... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4],l = 2,r = 4) == 3\n assert candidate(nums = [5, -1, 3, -2, 4],l = 1,r = 4) == 1\n assert candidate(nums = [1, -1, 1, -1, 1],l = 1,r = 5) == 1\n assert candidate(nums = [-1, -2, -3, -4],l = 2,r = 3) == -1\n ... | [
"[3,-2,1,4]\n2\n3",
"[-2,2,-3,1]\n2\n3",
"[1,2,3,4]\n2\n4"
] | [
"Check every subarray, since constraints are small."
] | {
"canonical_parameter_names": [
"nums",
"l",
"r"
],
"leetcode_dataset_entry_point": "Solution().minimumSumSubarray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:42",
"tests_... | rust | {
"raw_signature": "pub fn minimum_sum_subarray(nums: Vec<i32>, l: i32, r: i32) -> i32 {",
"container": "Solution",
"callable": "minimum_sum_subarray",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "l",
"type": "i32"
},
{
"name": "r",
"... |
3,365 | rearrange-k-substrings-to-form-target-string | Medium | You are given two strings s and t, both of which are anagrams of each other, and an integer k.
Your task is to determine whether it is possible to split the string s into k equal-sized substrings, rearrange the substrings, and concatenate them in any order to create a new string that matches the given string t.
Retur... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abcd\",t = \"cdab\",k = 2) == True\n assert candidate(s = \"abcdefg\",t = \"gfedcba\",k = 1) == False\n assert candidate(s = \"abcdefg\",t = \"gfedcba\",k = 7) == True\n assert candidate(s = \"aabbcc\",t = \"bbaacc\",k = 3... | [
"\"abcd\"\n\"cdab\"\n2",
"\"aabbcc\"\n\"bbaacc\"\n3",
"\"aabbcc\"\n\"bbaacc\"\n2"
] | [
"Split s into k equal-sized substrings, use a map to track frequencies, and check if rearranging them can form t."
] | {
"canonical_parameter_names": [
"s",
"t",
"k"
],
"leetcode_dataset_entry_point": "Solution().isPossibleToRearrange",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:45",
"tests_... | rust | {
"raw_signature": "pub fn is_possible_to_rearrange(s: String, t: String, k: i32) -> bool {",
"container": "Solution",
"callable": "is_possible_to_rearrange",
"parameters": [
{
"name": "s",
"type": "String"
},
{
"name": "t",
"type": "String"
},
{
"name": "k",
... |
3,366 | minimum-array-sum | Medium | You are given an integer array nums and three integers k, op1, and op2.
You can perform the following operations on nums:
- Operation 1: Choose an index i and divide nums[i] by 2, rounding up to the nearest whole number. You can perform this operation at most op1 times, and not more than once per index.
- Operation 2... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [0, 0, 0, 0],k = 0,op1 = 4,op2 = 4) == 0\n assert candidate(nums = [10, 20, 30],k = 10,op1 = 3,op2 = 2) == 10\n assert candidate(nums = [9, 18, 27, 36],k = 9,op1 = 2,op2 = 2) == 41\n assert candidate(nums = [10, 20, 30],k... | [
"[2,8,3,19,3]\n3\n1\n1",
"[2,4,3]\n3\n2\n1"
] | [
"Think of dynamic programming with states to track progress and remaining operations.",
"Use dp[index][op1][op2] where each state tracks progress at index with op1 and op2 operations left.",
"At each state, try applying only operation 1, only operation 2, both in sequence, or skip both to find optimal results."... | {
"canonical_parameter_names": [
"nums",
"k",
"op1",
"op2"
],
"leetcode_dataset_entry_point": "Solution().minArraySum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:47",
"... | rust | {
"raw_signature": "pub fn min_array_sum(nums: Vec<i32>, k: i32, op1: i32, op2: i32) -> i32 {",
"container": "Solution",
"callable": "min_array_sum",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "k",
"type": "i32"
},
{
"name": "op1",
"... |
3,367 | maximize-sum-of-weights-after-edge-removals | Hard | There exists an undirected tree with n nodes numbered 0 to n - 1. You are given a 2D integer array edges of length n - 1, where edges[i] = [u_i, v_i, w_i] indicates that there is an edge between nodes u_i and v_i with weight w_i in the tree.
Your task is to remove zero or more edges such that:
- Each node has an edge... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5]],k = 1) == 9\n assert candidate(edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]],k = 3) == 21\n assert candidate(edges = [[0, 1, 4], [0, 2, 2]... | [
"[[0,1,4],[0,2,2],[2,3,12],[2,4,6]]\n2",
"[[0,1,5],[1,2,10],[0,3,15],[3,4,20],[3,5,5],[0,6,10]]\n3"
] | [
"Can we use DFS based approach here?",
"For each edge, find two sums: one including the edge and one excluding it."
] | {
"canonical_parameter_names": [
"edges",
"k"
],
"leetcode_dataset_entry_point": "Solution().maximizeSumOfWeights",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:50",
"tests_total"... | rust | {
"raw_signature": "pub fn maximize_sum_of_weights(edges: Vec<Vec<i32>>, k: i32) -> i64 {",
"container": "Solution",
"callable": "maximize_sum_of_weights",
"parameters": [
{
"name": "edges",
"type": "Vec<Vec<i32>>"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "... |
3,370 | smallest-number-with-all-set-bits | Easy | You are given a positive number n.
Return the smallest number x greater than or equal to n, such that the binary representation of x contains only set bits
Example 1:
Input: n = 5
Output: 7
Explanation:
The binary representation of 7 is "111".
Example 2:
Input: n = 10
Output: 15
Explanation:
The binary representat... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 3) == 3\n assert candidate(n = 12) == 15\n assert candidate(n = 100) == 127\n assert candidate(n = 1000) == 1023\n assert candidate(n = 5) == 7\n assert candidate(n = 64) == 127\n assert candidate(n = 16) == 31\n ... | [
"5",
"10",
"3"
] | [
"Find the strictly greater power of 2, and subtract 1 from it."
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().smallestNumber",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:52",
"tests_total": 56,
"tests_drop... | rust | {
"raw_signature": "pub fn smallest_number(n: i32) -> i32 {",
"container": "Solution",
"callable": "smallest_number",
"parameters": [
{
"name": "n",
"type": "i32"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,371 | identify-the-largest-outlier-in-an-array | Medium | You are given an integer array nums. This array contains n elements, where exactly n - 2 elements are special numbers. One of the remaining two elements is the sum of these special numbers, and the other is an outlier.
An outlier is defined as a number that is neither one of the original special numbers nor the elemen... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1000, -1000, 0, 500, -500]) == 1000\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 25, 30]) == 30\n assert candidate(nums = [0, 0, 0, 0, 1]) == 1\n assert cand... | [
"[2,3,5,10]",
"[-2,-1,-3,-6,4]",
"[1,1,1,1,1,5,5]"
] | [
"What will be the value of array sum if we remove the outlier from it?",
"Use hashmap to find occurrence of an element quickly."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().getLargestOutlier",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:55",
"tests_total": 118,
"tes... | rust | {
"raw_signature": "pub fn get_largest_outlier(nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "get_largest_outlier",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
3,372 | maximize-the-number-of-target-nodes-after-connecting-trees-i | Medium | There exist two undirected trees with n and m nodes, with distinct labels in ranges [0, n - 1] and [0, m - 1], respectively.
You are given two 2D integer arrays edges1 and edges2 of lengths n - 1 and m - 1, respectively, where edges1[i] = [a_i, b_i] indicates that there is an edge between nodes a_i and b_i in the firs... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(edges1 = [[0, 1], [0, 2], [0, 3], [0, 4]],edges2 = [[0, 1], [1, 2], [2, 3]],k = 1) == [6, 3, 3, 3, 3]\n assert candidate(edges1 = [[0, 1], [0, 2], [2, 3], [2, 4]],edges2 = [[0, 1], [0, 2], [0, 3], [2, 7], [1, 4], [4, 5], [4, 6]],k = 2... | [
"[[0,1],[0,2],[2,3],[2,4]]\n[[0,1],[0,2],[0,3],[2,7],[1,4],[4,5],[4,6]]\n2",
"[[0,1],[0,2],[0,3],[0,4]]\n[[0,1],[1,2],[2,3]]\n1"
] | [
"For each node u in the first tree, find the number of nodes at a distance of at most k from node u.",
"For each node v in the second tree, find the number of nodes at a distance of at most k - 1 from node v."
] | {
"canonical_parameter_names": [
"edges1",
"edges2",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxTargetNodes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:22:57",
"tes... | rust | {
"raw_signature": "pub fn max_target_nodes(edges1: Vec<Vec<i32>>, edges2: Vec<Vec<i32>>, k: i32) -> Vec<i32> {",
"container": "Solution",
"callable": "max_target_nodes",
"parameters": [
{
"name": "edges1",
"type": "Vec<Vec<i32>>"
},
{
"name": "edges2",
"type": "Vec<Vec<i32>>... |
3,373 | maximize-the-number-of-target-nodes-after-connecting-trees-ii | Hard | There exist two undirected trees with n and m nodes, labeled from [0, n - 1] and [0, m - 1], respectively.
You are given two 2D integer arrays edges1 and edges2 of lengths n - 1 and m - 1, respectively, where edges1[i] = [a_i, b_i] indicates that there is an edge between nodes a_i and b_i in the first tree and edges2[... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4]],edges2 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [3, 6]]) == [7, 6, 6, 7, 7]\n assert candidate(edges1 = [[0, 1], [0, 2], [0, 3], [0, 4]],edges2 = [[0, 1], [1, 2], [2, 3]]) == [3, 6, 6, 6, 6]... | [
"[[0,1],[0,2],[2,3],[2,4]]\n[[0,1],[0,2],[0,3],[2,7],[1,4],[4,5],[4,6]]",
"[[0,1],[0,2],[0,3],[0,4]]\n[[0,1],[1,2],[2,3]]"
] | [
"Compute an array even where even[u] is the number of nodes at an even distance from node u, for every u of the first tree.",
"Compute an array odd where odd[u] is the number of nodes at an odd distance from node u, for every u of the second tree.",
"answer[i] = even[i]+ max(odd[1], odd[2], …, odd[m - 1])"
] | {
"canonical_parameter_names": [
"edges1",
"edges2"
],
"leetcode_dataset_entry_point": "Solution().maxTargetNodes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:01",
"tests_total"... | rust | {
"raw_signature": "pub fn max_target_nodes(edges1: Vec<Vec<i32>>, edges2: Vec<Vec<i32>>) -> Vec<i32> {",
"container": "Solution",
"callable": "max_target_nodes",
"parameters": [
{
"name": "edges1",
"type": "Vec<Vec<i32>>"
},
{
"name": "edges2",
"type": "Vec<Vec<i32>>"
}
... |
3,375 | minimum-operations-to-make-array-values-equal-to-k | Easy | You are given an integer array nums and an integer k.
An integer h is called valid if all values in the array that are strictly greater than h are identical.
For example, if nums = [10, 8, 10, 8], a valid integer is h = 9 because all nums[i] > 9 are equal to 10, but 5 is not a valid integer.
You are allowed to perfo... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [50, 40, 30, 20, 10],k = 10) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],k = 5) == -1\n assert candidate... | [
"[5,2,5,4,5]\n2",
"[2,1,2]\n2",
"[9,7,5,3]\n1"
] | [
"Handle the case when the array contains an integer less than k",
"Start by performing operations on the highest integer",
"You can perform an operation on the highest integer using the second-highest, an operation on the second-highest using the third-highest, and so forth.",
"The answer is the number of dis... | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().minOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:03",
"tests_total": 120,
... | rust | {
"raw_signature": "pub fn min_operations(nums: Vec<i32>, k: i32) -> i32 {",
"container": "Solution",
"callable": "min_operations",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "i32",
"signature_source": "l... |
3,376 | minimum-time-to-break-locks-i | Medium | Bob is stuck in a dungeon and must break n locks, each requiring some amount of energy to break. The required energy for each lock is stored in an array called strength where strength[i] indicates the energy needed to break the i^th lock.
To break a lock, Bob uses a sword with the following characteristics:
- The ini... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(strength = [1, 1, 1, 1],k = 1) == 4\n assert candidate(strength = [8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 8\n assert candidate(strength = [10, 9, 8, 7, 6, 5, 4, 3],k = 1) == 15\n assert candidate(strength = [2, 5, 4],k = 2) == 5\n ... | [
"[3,4,1]\n1",
"[2,5,4]\n2"
] | [
"Try all n! permutation ways of breaking the locks."
] | {
"canonical_parameter_names": [
"strength",
"k"
],
"leetcode_dataset_entry_point": "Solution().findMinimumTime",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:06",
"tests_total": ... | rust | {
"raw_signature": "pub fn find_minimum_time(strength: Vec<i32>, k: i32) -> i32 {",
"container": "Solution",
"callable": "find_minimum_time",
"parameters": [
{
"name": "strength",
"type": "Vec<i32>"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "i32",
"signatu... |
3,377 | digit-operations-to-make-two-integers-equal | Medium | You are given two integers n and m that consist of the same number of digits.
You can perform the following operations any number of times:
- Choose any digit from n that is not 9 and increase it by 1.
- Choose any digit from n that is not 0 and decrease it by 1.
The integer n must not be a prime number at any point... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 5678,m = 8765) == 57404\n assert candidate(n = 1009,m = 1010) == -1\n assert candidate(n = 1111,m = 2222) == 6789\n assert candidate(n = 3333,m = 4444) == 17899\n assert candidate(n = 1111,m = 2221) == -1\n assert cand... | [
"10\n12",
"4\n8",
"6\n2"
] | [
"Consider a directed, weighted graph where an edge exists from a node x to a node y if and only if x can be transformed into y through a single operation.",
"Apply a shortest path algorithm on this graph to find the shortest path from n to m."
] | {
"canonical_parameter_names": [
"n",
"m"
],
"leetcode_dataset_entry_point": "Solution().minOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:08",
"tests_total": 111,
"t... | rust | {
"raw_signature": "pub fn min_operations(n: i32, m: i32) -> i32 {",
"container": "Solution",
"callable": "min_operations",
"parameters": [
{
"name": "n",
"type": "i32"
},
{
"name": "m",
"type": "i32"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnip... |
3,378 | count-connected-components-in-lcm-graph | Hard | You are given an array of integers nums of size n and a positive integer threshold.
There is a graph consisting of n nodes with the i^th node having a value of nums[i]. Two nodes i and j in the graph are connected via an undirected edge if lcm(nums[i], nums[j]) <= threshold.
Return the number of connected components ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],threshold = 4) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],threshold = 3) == 3\n assert candidate(nums = [6, 12, 18, 24, 30],threshold = 30) == 1\n assert candidate(nums = [100, 200, 300, 400, 500],thre... | [
"[2,4,8,3,9]\n5",
"[2,4,8,3,9,12]\n10"
] | [
"Use DSU",
"Connect a number to all its multiples less than threshold"
] | {
"canonical_parameter_names": [
"nums",
"threshold"
],
"leetcode_dataset_entry_point": "Solution().countComponents",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:11",
"tests_tota... | rust | {
"raw_signature": "pub fn count_components(nums: Vec<i32>, threshold: i32) -> i32 {",
"container": "Solution",
"callable": "count_components",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "threshold",
"type": "i32"
}
],
"return_type": "i32",
"s... |
3,379 | transformed-array | Easy | You are given an integer array nums that represents a circular array. Your task is to create a new array result of the same size, following these rules:
For each index i (where 0 <= i < nums.length), perform the following independent actions:
- If nums[i] > 0: Start at index i and move nums[i] steps to the right in th... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == [-1, 1, 3, -1, -1, 2]\n assert candidate(nums = [3, -2, 1, 1]) == [1, 1, 1, 3]\n assert candidate(nums = [10, -10, 20, -20]) == [20, -20, 20, -20]\n assert candidate(nums = [-4, -3, -2, -1]) == [... | [
"[3,-2,1,1]",
"[-1,4,-1]"
] | [
"Simulate the operations as described in the statement"
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().constructTransformedArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:13",
"tests_total": 126... | rust | {
"raw_signature": "pub fn construct_transformed_array(nums: Vec<i32>) -> Vec<i32> {",
"container": "Solution",
"callable": "construct_transformed_array",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "Vec<i32>",
"signature_source": "leetcode/codeSnippets",
... |
3,380 | maximum-area-rectangle-with-point-constraints-i | Medium | You are given an array points where points[i] = [x_i, y_i] represents the coordinates of a point on an infinite plane.
Your task is to find the maximum area of a rectangle that:
- Can be formed using four of these points as its corners.
- Does not contain any other point inside or on its border.
- Has its edges paral... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3]]) == 1\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1], [0, 2], [1, 2], [2, 2]]) == 1\n assert candidate(points = [[1, 1], [1, 2],... | [
"[[1,1],[1,3],[3,1],[3,3]]",
"[[1,1],[1,3],[3,1],[3,3],[2,2]]",
"[[1,1],[1,3],[3,1],[3,3],[1,2],[3,2]]"
] | [
"If (x1, y1) and (x2, y2) are two opposite corners of a rectangle, then the other two would be (x1, y2) and (x2, y1).",
"Fix two points and find the other two using a set data structure.",
"After determining the rectangle, iterate through the array of points to ensure no point lies on the rectangle’s border or ... | {
"canonical_parameter_names": [
"points"
],
"leetcode_dataset_entry_point": "Solution().maxRectangleArea",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:15",
"tests_total": 93,
"tes... | rust | {
"raw_signature": "pub fn max_rectangle_area(points: Vec<Vec<i32>>) -> i32 {",
"container": "Solution",
"callable": "max_rectangle_area",
"parameters": [
{
"name": "points",
"type": "Vec<Vec<i32>>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source"... |
3,381 | maximum-subarray-sum-with-length-divisible-by-k | Medium | You are given an array of integers nums and an integer k.
Return the maximum sum of a subarray of nums, such that the size of the subarray is divisible by k.
Example 1:
Input: nums = [1,2], k = 1
Output: 3
Explanation:
The subarray [1, 2] with sum 3 has length equal to 2 which is divisible by 1.
Example 2:
Input: ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000],k = 2) == 0\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000],k = 2) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k ... | [
"[1,2]\n1",
"[-1,-2,-3,-4,-5]\n4",
"[-5,1,2,-3,4]\n2"
] | [
"Maintain minimum prefix sum ending at every possible index%k."
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxSubarraySum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:19",
"tests_total": 128,
... | rust | {
"raw_signature": "pub fn max_subarray_sum(nums: Vec<i32>, k: i32) -> i64 {",
"container": "Solution",
"callable": "max_subarray_sum",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "i64",
"signature_source"... |
3,382 | maximum-area-rectangle-with-point-constraints-ii | Hard | There are n points on an infinite plane. You are given two integer arrays xCoord and yCoord where (xCoord[i], yCoord[i]) represents the coordinates of the i^th point.
Your task is to find the maximum area of a rectangle that:
- Can be formed using four of these points as its corners.
- Does not contain any other poin... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(xCoord = [5, 5, 7, 7],yCoord = [5, 7, 5, 7]) == 4\n assert candidate(xCoord = [1, 1, 10, 10],yCoord = [1, 10, 1, 10]) == 81\n assert candidate(xCoord = [1, 1, 3, 3, 1, 3],yCoord = [1, 3, 1, 3, 2, 2]) == 2\n assert candidate(xCoo... | [
"[1,1,3,3]\n[1,3,1,3]",
"[1,1,3,3,2]\n[1,3,1,3,2]",
"[1,1,3,3,1,3]\n[1,3,1,3,2,2]"
] | [
"Process the points by sorting them based on their x-coordinates.",
"For each x-coordinate, sort the corresponding points by y and select two consecutive points y1 and y2 (y1 < y2).",
"Identify the closest x-coordinate (greater than the current x) where some y-coordinates lie in [y1, y2].",
"Use a segment tre... | {
"canonical_parameter_names": [
"xCoord",
"yCoord"
],
"leetcode_dataset_entry_point": "Solution().maxRectangleArea",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:22",
"tests_tota... | rust | {
"raw_signature": "pub fn max_rectangle_area(x_coord: Vec<i32>, y_coord: Vec<i32>) -> i64 {",
"container": "Solution",
"callable": "max_rectangle_area",
"parameters": [
{
"name": "x_coord",
"type": "Vec<i32>"
},
{
"name": "y_coord",
"type": "Vec<i32>"
}
],
"return_ty... |
3,386 | button-with-longest-push-time | Easy | You are given a 2D array events which represents a sequence of events where a child pushes a series of buttons on a keyboard.
Each events[i] = [index_i, time_i] indicates that the button at index index_i was pressed at time time_i.
- The array is sorted in increasing order of time.
- The time taken to press a button ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(events = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 1\n assert candidate(events = [[3, 1], [1, 3], [2, 6], [3, 10]]) == 3\n assert candidate(events = [[10, 5], [1, 7]]) == 10\n assert candidate(events = [[100, 100], [200, 200]... | [
"[[1,2],[2,5],[3,9],[1,15]]",
"[[10,5],[1,7]]"
] | [] | {
"canonical_parameter_names": [
"events"
],
"leetcode_dataset_entry_point": "Solution().buttonWithLongestTime",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:27",
"tests_total": 104,
... | rust | {
"raw_signature": "pub fn button_with_longest_time(events: Vec<Vec<i32>>) -> i32 {",
"container": "Solution",
"callable": "button_with_longest_time",
"parameters": [
{
"name": "events",
"type": "Vec<Vec<i32>>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"... |
3,388 | count-beautiful-splits-in-an-array | Medium | You are given an array nums.
A split of an array nums is beautiful if:
1. The array nums is split into three subarrays: nums1, nums2, and nums3, such that nums can be formed by concatenating nums1, nums2, and nums3 in that order.
2. The subarray nums1 is a prefix of nums2 OR nums2 is a prefix of nums3.
Return the nu... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 1, 2, 3]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1]) == 3\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0]) == 19\n assert candidate(nums ... | [
"[1,1,2,1]",
"[1,2,3,4]"
] | [
"Use 2D dynamic programming to find the maximum matching prefix."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().beautifulSplits",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:31",
"tests_total": 107,
"tests... | rust | {
"raw_signature": "pub fn beautiful_splits(nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "beautiful_splits",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
3,389 | minimum-operations-to-make-character-frequencies-equal | Hard | You are given a string s.
A string t is called good if all characters of t occur the same number of times.
You can perform the following operations any number of times:
- Delete a character from s.
- Insert a character in s.
- Change a character in s to its next letter in the alphabet.
Note that you cannot change '... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"acab\") == 1\n assert candidate(s = \"aaabc\") == 2\n assert candidate(s = \"aabbbccc\") == 1\n assert candidate(s = \"zzzz\") == 0\n assert candidate(s = \"aabbcc\") == 0\n assert candidate(s = \"abcdefghijklmnopqrs... | [
"\"acab\"",
"\"wddw\"",
"\"aaabbc\""
] | [
"The order of the letters in the string is irrelevant.",
"Compute an occurrence array occ where occ[x] is the number of occurrences of the x character of the alphabet. How do the described operations change occ?",
"We have three types of operations: increase any occ[x] by 1, decrease any occ[x] by 1, or decreas... | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().makeStringGood",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:34",
"tests_total": 40,
"tests_drop... | rust | {
"raw_signature": "pub fn make_string_good(s: String) -> i32 {",
"container": "Solution",
"callable": "make_string_good",
"parameters": [
{
"name": "s",
"type": "String"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,392 | count-subarrays-of-length-three-with-a-condition | Easy | Given an integer array nums, return the number of subarrays of length 3 such that the sum of the first and third numbers equals exactly half of the second number.
Example 1:
Input: nums = [1,2,1,4,1]
Output: 1
Explanation:
Only the subarray [1,4,1] contains exactly 3 elements where the sum of the first and third numb... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 10, 5, 15, 5]) == 0\n assert candidate(nums = [1, 1, 1]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [100, -50, -50, 100, 100, -100, -100, 100]) == 1\n assert candidate(nums = [... | [
"[1,2,1,4,1]",
"[1,1,1]"
] | [
"The constraints are small. Consider checking every subarray."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countSubarrays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:36",
"tests_total": 134,
"tests_... | rust | {
"raw_signature": "pub fn count_subarrays(nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "count_subarrays",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
3,393 | count-paths-with-the-given-xor-value | Medium | You are given a 2D integer array grid with size m x n. You are also given an integer k.
Your task is to calculate the number of paths you can take from the top-left cell (0, 0) to the bottom-right cell (m - 1, n - 1) satisfying the following constraints:
- You can either move to the right or down. Formally, from the ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[1, 3, 3, 3], [0, 3, 3, 2], [3, 0, 1, 1]],k = 2) == 5\n assert candidate(grid = [[15, 15], [15, 15]],k = 14) == 0\n assert candidate(grid = [[1], [1], [1]],k = 1) == 1\n assert candidate(grid = [[1]],k = 1) == 1\n ass... | [
"[[2,1,5],[7,10,0],[12,6,4]]\n11",
"[[1,3,3,3],[0,3,3,2],[3,0,1,1]]\n2",
"[[1,1,1,2],[3,0,3,2],[3,0,2,2]]\n10"
] | [
"Use DP."
] | {
"canonical_parameter_names": [
"grid",
"k"
],
"leetcode_dataset_entry_point": "Solution().countPathsWithXorValue",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:38",
"tests_total... | rust | {
"raw_signature": "pub fn count_paths_with_xor_value(grid: Vec<Vec<i32>>, k: i32) -> i32 {",
"container": "Solution",
"callable": "count_paths_with_xor_value",
"parameters": [
{
"name": "grid",
"type": "Vec<Vec<i32>>"
},
{
"name": "k",
"type": "i32"
}
],
"return_type... |
3,395 | subsequences-with-a-unique-middle-mode-i | Hard | Given an integer array nums, find the number of subsequences of size 5 of nums with a unique middle mode.
Since the answer may be very large, return it modulo 10^9 + 7.
A mode of a sequence of numbers is defined as the element that appears the maximum number of times in the sequence.
A sequence of numbers contains a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1]) == 5613\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4... | [
"[1,1,1,1,1,1]",
"[1,2,2,3,3,4]",
"[0,1,2,3,4,5,6,7,8]"
] | [
"For each index, find the number of subsequences for which it is the unique middle mode. What combinations of values can the two numbers on the left and the right take?",
"For example, we can have exactly 1 element on the left equal to the middle and all other elements differ. What other combinations are acceptab... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().subsequencesWithMiddleMode",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:44",
"tests_total": 13... | rust | {
"raw_signature": "pub fn subsequences_with_middle_mode(nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "subsequences_with_middle_mode",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type... |
3,396 | minimum-number-of-operations-to-make-elements-in-array-distinct | Easy | You are given an integer array nums. You need to ensure that the elements in the array are distinct. To achieve this, you can perform the following operation any number of times:
- Remove 3 elements from the beginning of the array. If the array has fewer than 3 elements, remove all remaining elements.
Note that an em... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [4, 5, 6, 4, 4]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [10, 20, 30, 10, 20, 30, 10, 20, 30]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n a... | [
"[1,2,3,4,2,3,3,5,7]",
"[4,5,6,4,4]",
"[6,7,8,9]"
] | [
"The constraints are small. Try brute force."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().minimumOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:46",
"tests_total": 116,
"tes... | rust | {
"raw_signature": "pub fn minimum_operations(nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "minimum_operations",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
3,397 | maximum-number-of-distinct-elements-after-operations | Medium | You are given an integer array nums and an integer k.
You are allowed to perform the following operation on each element of the array at most once:
- Add an integer in the range [-k, k] to the element.
Return the maximum possible number of distinct elements in nums after performing the operations.
Example 1:
Input... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 1000000000, 1, 1000000000],k = 1000000000) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 5\n assert candidate(nums = [10, 10, 10, 10, 10],k = 5) == 5\n assert candidate(nums = [1, 1, 1, 1, 1],k = 0) == 1\n ... | [
"[1,2,2,3,3,4]\n2",
"[4,4,4,4]\n1"
] | [
"Can we use sorting here?",
"Find the minimum element which is not used for each element."
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxDistinctElements",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:48",
"tests_total": ... | rust | {
"raw_signature": "pub fn max_distinct_elements(nums: Vec<i32>, k: i32) -> i32 {",
"container": "Solution",
"callable": "max_distinct_elements",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "i32",
"signatu... |
3,398 | smallest-substring-with-identical-characters-i | Hard | You are given a binary string s of length n and an integer numOps.
You are allowed to perform the following operation on s at most numOps times:
- Select any index i (where 0 <= i < n) and flip s[i]. If s[i] == '1', change s[i] to '0' and vice versa.
You need to minimize the length of the longest substring of s such... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"111000\",numOps = 1) == 3\n assert candidate(s = \"11111\",numOps = 2) == 1\n assert candidate(s = \"101010\",numOps = 3) == 1\n assert candidate(s = \"1100110011\",numOps = 3) == 2\n assert candidate(s = \"001100\",num... | [
"\"000001\"\n1",
"\"0000\"\n2",
"\"0101\"\n0"
] | [
"Can we use binary search here?",
"Use DP for predicate function"
] | {
"canonical_parameter_names": [
"s",
"numOps"
],
"leetcode_dataset_entry_point": "Solution().minLength",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:50",
"tests_total": 120,
"... | rust | {
"raw_signature": "pub fn min_length(s: String, num_ops: i32) -> i32 {",
"container": "Solution",
"callable": "min_length",
"parameters": [
{
"name": "s",
"type": "String"
},
{
"name": "num_ops",
"type": "i32"
}
],
"return_type": "i32",
"signature_source": "leetcod... |
3,399 | smallest-substring-with-identical-characters-ii | Hard | You are given a binary string s of length n and an integer numOps.
You are allowed to perform the following operation on s at most numOps times:
- Select any index i (where 0 <= i < n) and flip s[i]. If s[i] == '1', change s[i] to '0' and vice versa.
You need to minimize the length of the longest substring of s such... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"000001\",numOps = 1) == 2\n assert candidate(s = \"111000\",numOps = 2) == 1\n assert candidate(s = \"11111111\",numOps = 3) == 2\n assert candidate(s = \"111110\",numOps = 2) == 1\n assert candidate(s = \"101010\",numO... | [
"\"000001\"\n1",
"\"0000\"\n2",
"\"0101\"\n0"
] | [
"Binary search for the answer.",
"Group the same digits by size of (mid + 1) and ignore any remainder. Flip one in each group (the last one).",
"For the last group, we can flip the 2nd last one.",
"What if the answer was 1?"
] | {
"canonical_parameter_names": [
"s",
"numOps"
],
"leetcode_dataset_entry_point": "Solution().minLength",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:52",
"tests_total": 128,
"... | rust | {
"raw_signature": "pub fn min_length(s: String, num_ops: i32) -> i32 {",
"container": "Solution",
"callable": "min_length",
"parameters": [
{
"name": "s",
"type": "String"
},
{
"name": "num_ops",
"type": "i32"
}
],
"return_type": "i32",
"signature_source": "leetcod... |
3,402 | minimum-operations-to-make-columns-strictly-increasing | Easy | You are given a m x n matrix grid consisting of non-negative integers.
In one operation, you can increment the value of any grid[i][j] by 1.
Return the minimum number of operations needed to make all columns of grid strictly increasing.
Example 1:
Input: grid = [[3,2],[1,3],[3,4],[0,1]]
Output: 15
Explanation:
- To... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 9\n assert candidate(grid = [[0, 0, 0], [1, 1, 1], [2, 2, 2]]) == 0\n assert candidate(grid = [[3, 2, 1], [2, 1, 0], [1, 2, 3]]) == 12\n assert candidate(grid = [[10, 20], [15, 25], [... | [
"[[3,2],[1,3],[3,4],[0,1]]",
"[[3,2,1],[2,1,0],[1,2,3]]"
] | [
"grid[i + 1][j] must be at least equal to grid[i][j] + 1.",
"Iterate on i in increasing order, and set grid[i + 1][j] = max(grid[i][j]+1, grid[i + 1][j])."
] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().minimumOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:57",
"tests_total": 93,
"test... | rust | {
"raw_signature": "pub fn minimum_operations(grid: Vec<Vec<i32>>) -> i32 {",
"container": "Solution",
"callable": "minimum_operations",
"parameters": [
{
"name": "grid",
"type": "Vec<Vec<i32>>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "l... |
3,403 | find-the-lexicographically-largest-string-from-the-box-i | Medium | You are given a string word, and an integer numFriends.
Alice is organizing a game for her numFriends friends. There are multiple rounds in the game, where in each round:
- word is split into numFriends non-empty strings, such that no previous round has had the exact same split.
- All the split words are put into a b... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word = \"aabbcc\",numFriends = 2) == \"cc\"\n assert candidate(word = \"zxy\",numFriends = 1) == \"zxy\"\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\",numFriends = 5) == \"zyxwvutsrqponmlkjihgfe\"\n assert candidate(w... | [
"\"dbca\"\n2",
"\"gggg\"\n4"
] | [
"Find lexicographically largest substring of size n - numFriends + 1 or less starting at every index."
] | {
"canonical_parameter_names": [
"word",
"numFriends"
],
"leetcode_dataset_entry_point": "Solution().answerString",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:23:59",
"tests_total"... | rust | {
"raw_signature": "pub fn answer_string(word: String, num_friends: i32) -> String {",
"container": "Solution",
"callable": "answer_string",
"parameters": [
{
"name": "word",
"type": "String"
},
{
"name": "num_friends",
"type": "i32"
}
],
"return_type": "String",
"s... |
3,404 | count-special-subsequences | Medium | You are given an array nums consisting of positive integers.
A special subsequence is defined as a subsequence of length 4, represented by indices (p, q, r, s), where p < q < r < s. This subsequence must satisfy the following conditions:
- nums[p] * nums[r] == nums[q] * nums[s]
- There must be at least one element be... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [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]) == 17550\n assert candidate(nums = [10, 20, 30, 40, 10, 20, 30, 40, 10, 20, 30, 40, 10]) == 23\n assert candidate(nums = [1, 1, 2, 2... | [
"[1,2,3,4,3,6,1]",
"[3,4,3,4,3,4,3,4]"
] | [
"Count pairs where nums[p] / nums[q] equals nums[s] / nums[r], using GCD to handle ratios efficiently.",
"Try iterating over (p, q) pairs and efficiently count valid (r, s) pairs with the same ratio."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().numberOfSubsequences",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:01",
"tests_total": 127,
"... | rust | {
"raw_signature": "pub fn number_of_subsequences(nums: Vec<i32>) -> i64 {",
"container": "Solution",
"callable": "number_of_subsequences",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i64",
"signature_source": "leetcode/codeSnippets",
"type_source": "lee... |
3,407 | substring-matching-pattern | Easy | You are given a string s and a pattern string p, where p contains exactly one '*' character.
The '*' in p can be replaced with any sequence of zero or more characters.
Return true if p can be made a substring of s, and false otherwise.
Example 1:
Input: s = "leetcode", p = "ee*e"
Output: true
Explanation:
By replac... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"luck\",p = \"u*\") == True\n assert candidate(s = \"xy\",p = \"*\") == True\n assert candidate(s = \"leetcode\",p = \"ee*e\") == True\n assert candidate(s = \"testcase\",p = \"te*se\") == True\n assert candidate(s = \"c... | [
"\"leetcode\"\n\"ee*e\"",
"\"car\"\n\"c*v\"",
"\"luck\"\n\"u*\""
] | [
"Divide the pattern in two strings and search in the string."
] | {
"canonical_parameter_names": [
"s",
"p"
],
"leetcode_dataset_entry_point": "Solution().hasMatch",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:09",
"tests_total": 209,
"tests_... | rust | {
"raw_signature": "pub fn has_match(s: String, p: String) -> bool {",
"container": "Solution",
"callable": "has_match",
"parameters": [
{
"name": "s",
"type": "String"
},
{
"name": "p",
"type": "String"
}
],
"return_type": "bool",
"signature_source": "leetcode/code... |
3,409 | longest-subsequence-with-decreasing-adjacent-difference | Medium | You are given an array of integers nums.
Your task is to find the length of the longest subsequence seq of nums, such that the absolute differences between consecutive elements form a non-increasing sequence of integers. In other words, for a subsequence seq_0, seq_1, seq_2, ..., seq_m of nums, |seq_1 - seq_0| >= |seq... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 6\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10]) == 8\n assert candidate(nums = [300, 1, 300, 2, 300, 3, 300]) == 7\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == ... | [
"[16,6,3]",
"[6,5,3,4,2,1]",
"[10,20,10,19,10,20]"
] | [
"Use dynamic programming.",
"Store the maximum answer for each index and every possible difference."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().longestSubsequence",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:11",
"tests_total": 121,
"te... | rust | {
"raw_signature": "pub fn longest_subsequence(nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "longest_subsequence",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
3,410 | maximize-subarray-sum-after-removing-all-occurrences-of-one-element | Hard | You are given an integer array nums.
You can do the following operation on the array at most once:
- Choose any integer x such that nums remains non-empty on removing all occurrences of x.
- Remove all occurrences of x from the array.
Return the maximum subarray sum across all possible resulting arrays.
Example 1:
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, -1, 3, -2, 4, -3, 5]) == 12\n assert candidate(nums = [1, -1, 1, -1, 1]) == 3\n assert candidate(nums = [1, 2, 2, 1]) == 6\n assert candidate(nums = [5, -3, 5, -2, 5, -1, 5]) == 17\n assert candidate(nums = [-3,... | [
"[-3,2,-2,-1,3,-2,3]",
"[1,2,3,4]"
] | [
"Use a segment tree data structure to solve the problem.",
"Each node of the segment tree should store the subarray sum, the maximum subarray sum, the maximum prefix sum, and the maximum suffix sum within the subarray defined by that node."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maxSubarraySum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:14",
"tests_total": 140,
"tests_... | rust | {
"raw_signature": "pub fn max_subarray_sum(nums: Vec<i32>) -> i64 {",
"container": "Solution",
"callable": "max_subarray_sum",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i64",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
3,411 | maximum-subarray-with-equal-products | Easy | You are given an array of positive integers nums.
An array arr is called product equivalent if prod(arr) == lcm(arr) * gcd(arr), where:
- prod(arr) is the product of all elements of arr.
- gcd(arr) is the GCD of all elements of arr.
- lcm(arr) is the LCM of all elements of arr.
Return the length of the longest produ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [6, 3, 2, 1, 5, 4]) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert... | [
"[1,2,1,2,1,1,1]",
"[2,3,4,5,6]",
"[1,2,3,1,4,5,1]"
] | [
"What is the maximum possible lcm?"
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maxLength",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:16",
"tests_total": 126,
"tests_dropp... | rust | {
"raw_signature": "pub fn max_length(nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "max_length",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,412 | find-mirror-score-of-a-string | Medium | You are given a string s.
We define the mirror of a letter in the English alphabet as its corresponding letter when the alphabet is reversed. For example, the mirror of 'a' is 'z', and the mirror of 'y' is 'b'.
Initially, all characters in the string s are unmarked.
You start with a score of 0, and you perform the f... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"b\") == 0\n assert candidate(s = \"mirror\") == 1\n assert candidate(s = \"az\") == 1\n assert candidate(s = \"abbabba\") == 0\n assert candidate(s = \"abcba\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxy... | [
"\"aczzx\"",
"\"abcdef\""
] | [
"Create a stack for every character.",
"For each index, check if the stack for mirror of the letter at that index is empty."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().calculateScore",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:18",
"tests_total": 74,
"tests_drop... | rust | {
"raw_signature": "pub fn calculate_score(s: String) -> i64 {",
"container": "Solution",
"callable": "calculate_score",
"parameters": [
{
"name": "s",
"type": "String"
}
],
"return_type": "i64",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,413 | maximum-coins-from-k-consecutive-bags | Medium | There are an infinite amount of bags on a number line, one bag for each coordinate. Some of these bags contain coins.
You are given a 2D array coins, where coins[i] = [l_i, r_i, c_i] denotes that every bag from l_i to r_i contains c_i coins.
The segments that coins contain are non-overlapping.
You are also given an ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(coins = [[8, 10, 1], [1, 3, 2], [5, 6, 4]],k = 4) == 10\n assert candidate(coins = [[1, 10, 3]],k = 2) == 6\n assert candidate(coins = [[10, 20, 5], [30, 40, 10], [50, 60, 15]],k = 5) == 75\n assert candidate(coins = [[1, 2, 5],... | [
"[[8,10,1],[1,3,2],[5,6,4]]\n4",
"[[1,10,3]]\n2"
] | [
"An optimal starting position for k consecutive bags will be either l_i or r_i - k + 1."
] | {
"canonical_parameter_names": [
"coins",
"k"
],
"leetcode_dataset_entry_point": "Solution().maximumCoins",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:21",
"tests_total": 115,
... | rust | {
"raw_signature": "pub fn maximum_coins(coins: Vec<Vec<i32>>, k: i32) -> i64 {",
"container": "Solution",
"callable": "maximum_coins",
"parameters": [
{
"name": "coins",
"type": "Vec<Vec<i32>>"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "i64",
"signature_s... |
3,417 | zigzag-grid-traversal-with-skip | Easy | You are given an m x n 2D array grid of positive integers.
Your task is to traverse grid in a zigzag pattern while skipping every alternate cell.
Zigzag pattern traversal is defined as following the below actions:
- Start at the top-left cell (0, 0).
- Move right within a row until the end of the row is reached.
- D... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[1, 3, 5], [2, 4, 6], [7, 9, 11], [8, 10, 12]]) == [1, 5, 4, 7, 11, 10]\n assert candidate(grid = [[2, 4, 6], [8, 10, 12], [14, 16, 18], [20, 22, 24], [26, 28, 30]]) == [2, 6, 10, 14, 18, 22, 26, 30]\n assert candidate(grid... | [
"[[1,2],[3,4]]",
"[[2,1],[2,1],[2,1]]",
"[[1,2,3],[4,5,6],[7,8,9]]"
] | [] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().zigzagTraversal",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:26",
"tests_total": 71,
"tests_... | rust | {
"raw_signature": "pub fn zigzag_traversal(grid: Vec<Vec<i32>>) -> Vec<i32> {",
"container": "Solution",
"callable": "zigzag_traversal",
"parameters": [
{
"name": "grid",
"type": "Vec<Vec<i32>>"
}
],
"return_type": "Vec<i32>",
"signature_source": "leetcode/codeSnippets",
"type_sourc... |
3,418 | maximum-amount-of-money-robot-can-earn | Medium | You are given an m x n grid. A robot starts at the top-left corner of the grid (0, 0) and wants to reach the bottom-right corner (m - 1, n - 1). The robot can move either right or down at any point in time.
The grid contains a value coins[i][j] in each cell:
- If coins[i][j] >= 0, the robot gains that many coins.
- I... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(coins = [[0, 1, -1], [1, -2, 3], [2, -3, 4]]) == 8\n assert candidate(coins = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9]]) == 34\n assert candidate(coins = [[1000, -1000, 1000, -1000], [-1000, 1000, -1000, 1000], [1000, -10... | [
"[[0,1,-1],[1,-2,3],[2,-3,4]]",
"[[10,10,10],[10,10,10]]"
] | [
"Use Dynamic Programming.",
"Let dp[i][j][k] denote the maximum amount of money a robot can earn by starting at cell (i,j) and having neutralized k robbers."
] | {
"canonical_parameter_names": [
"coins"
],
"leetcode_dataset_entry_point": "Solution().maximumAmount",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:29",
"tests_total": 85,
"tests_d... | rust | {
"raw_signature": "pub fn maximum_amount(coins: Vec<Vec<i32>>) -> i32 {",
"container": "Solution",
"callable": "maximum_amount",
"parameters": [
{
"name": "coins",
"type": "Vec<Vec<i32>>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcod... |
3,419 | minimize-the-maximum-edge-weight-of-graph | Medium | You are given two integers, n and threshold, as well as a directed weighted graph of n nodes numbered from 0 to n - 1. The graph is represented by a 2D integer array edges, where edges[i] = [A_i, B_i, W_i] indicates that there is an edge going from node A_i to node B_i with weight W_i.
You have to remove some edges fr... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 5,edges = [[1, 2, 1], [1, 3, 3], [1, 4, 5], [2, 3, 2], [3, 4, 2], [4, 0, 1]],threshold = 1) == 2\n assert candidate(n = 5,edges = [[1, 0, 1], [2, 0, 2], [3, 0, 1], [4, 3, 1], [2, 1, 1]],threshold = 2) == 1\n assert candidate(n ... | [
"5\n[[1,0,1],[2,0,2],[3,0,1],[4,3,1],[2,1,1]]\n2",
"5\n[[0,1,1],[0,2,2],[0,3,1],[0,4,1],[1,2,1],[1,4,1]]\n1",
"5\n[[1,2,1],[1,3,3],[1,4,5],[2,3,2],[3,4,2],[4,0,1]]\n1",
"5\n[[1,2,1],[1,3,3],[1,4,5],[2,3,2],[4,0,1]]\n1"
] | [
"Can we use binary search?",
"Invert the edges in the graph."
] | {
"canonical_parameter_names": [
"n",
"edges",
"threshold"
],
"leetcode_dataset_entry_point": "Solution().minMaxWeight",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:32",
"tes... | rust | {
"raw_signature": "pub fn min_max_weight(n: i32, edges: Vec<Vec<i32>>, threshold: i32) -> i32 {",
"container": "Solution",
"callable": "min_max_weight",
"parameters": [
{
"name": "n",
"type": "i32"
},
{
"name": "edges",
"type": "Vec<Vec<i32>>"
},
{
"name": "thr... |
3,420 | count-non-decreasing-subarrays-after-k-operations | Hard | You are given an array nums of n integers and an integer k.
For each subarray of nums, you can apply up to k operations on it. In each operation, you increment any element of the subarray by 1.
Note that each subarray is considered independently, meaning changes made to one subarray do not persist to another.
Return... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1],k = 10) == 15\n assert candidate(nums = [10, 20, 10, 20, 10],k = 15) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 55\n assert candidate(nums = [1, 100, 2, 99, 3, 98],k = 100) =... | [
"[6,3,1,2,4,4]\n7",
"[6,3,1,3,6]\n4"
] | [
"Use a sparse table.",
"Compute sp[e][i] = [lastElement, operations] where operations is the number of operations required to make the subarray nums[i...i + 2^e - 1] non-decreasing, and lastElement be the value of the last element after the operations were applied on it.",
"How can we combine sp[a][i] with sp[b... | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().countNonDecreasingSubarrays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:35",
"tests_... | rust | {
"raw_signature": "pub fn count_non_decreasing_subarrays(nums: Vec<i32>, k: i32) -> i64 {",
"container": "Solution",
"callable": "count_non_decreasing_subarrays",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "k",
"type": "i32"
}
],
"return_type":... |
3,423 | maximum-difference-between-adjacent-elements-in-a-circular-array | Easy | Given a circular array nums, find the maximum absolute difference between adjacent elements.
Note: In a circular array, the first and last elements are adjacent.
Example 1:
Input: nums = [1,2,4]
Output: 3
Explanation:
Because nums is circular, nums[0] and nums[2] are adjacent. They have the maximum absolute differen... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [100, 1, 100, 1, 100]) == 99\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 50\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == 6\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 45\n as... | [
"[1,2,4]",
"[-5,-10,-5]"
] | [
"Traverse from the second element to the last element and check the difference of every adjacent pair.",
"The edge case is to check the difference between the first and last elements."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maxAdjacentDistance",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:40",
"tests_total": 120,
"t... | rust | {
"raw_signature": "pub fn max_adjacent_distance(nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "max_adjacent_distance",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetc... |
3,424 | minimum-cost-to-make-arrays-identical | Medium | You are given two integer arrays arr and brr of length n, and an integer k. You can perform the following operations on arr any number of times:
- Split arr into any number of contiguous subarrays and rearrange these subarrays in any order. This operation has a fixed cost of k.
-
Choose any element in arr and add or s... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [0, 0, 0],brr = [0, 0, 0],k = 10) == 0\n assert candidate(arr = [2, 1],brr = [2, 1],k = 0) == 0\n assert candidate(arr = [0, 0, 0],brr = [0, 0, 0],k = 100) == 0\n assert candidate(arr = [1, 2, 3],brr = [3, 2, 1],k = 10) ==... | [
"[-7,9,5]\n[7,-2,-5]\n2",
"[2,1]\n[2,1]\n0"
] | [
"What does Operation 1 (rearranging subarrays) actually accomplish?",
"Calculate sum(abs(arr[i] - brr[i])) if you do not use Operation 1.",
"Calculate sum(abs(arr[i] - brr[i])) after sorting both arrays if you use Operation 1."
] | {
"canonical_parameter_names": [
"arr",
"brr",
"k"
],
"leetcode_dataset_entry_point": "Solution().minCost",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:44",
"tests_total": 12... | rust | {
"raw_signature": "pub fn min_cost(arr: Vec<i32>, brr: Vec<i32>, k: i64) -> i64 {",
"container": "Solution",
"callable": "min_cost",
"parameters": [
{
"name": "arr",
"type": "Vec<i32>"
},
{
"name": "brr",
"type": "Vec<i32>"
},
{
"name": "k",
"type": "i64"... |
3,426 | manhattan-distances-of-all-arrangements-of-pieces | Hard | You are given three integers m, n, and k.
There is a rectangular grid of size m × n containing k identical pieces. Return the sum of Manhattan distances between every pair of pieces over all valid arrangements of pieces.
A valid arrangement is a placement of all k pieces on the grid with at most one piece per cell.
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(m = 5,n = 5,k = 5) == 1771000\n assert candidate(m = 100,n = 100,k = 10) == 384963906\n assert candidate(m = 10,n = 10,k = 20) == 80781589\n assert candidate(m = 1,n = 4,k = 3) == 20\n assert candidate(m = 10,n = 10,k = 10) =... | [
"2\n2\n2",
"1\n4\n3"
] | [
"Fix two pieces in two specific locations and find the number of boards where this can happen.",
"A particular pair of positions will be counted exactly C(m * n - 2, k - 2) times. Calculate the total distance for all pairs of positions and multiply it with C(m * n - 2, k - 2)."
] | {
"canonical_parameter_names": [
"m",
"n",
"k"
],
"leetcode_dataset_entry_point": "Solution().distanceSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:49",
"tests_total": 89... | rust | {
"raw_signature": "pub fn distance_sum(m: i32, n: i32, k: i32) -> i32 {",
"container": "Solution",
"callable": "distance_sum",
"parameters": [
{
"name": "m",
"type": "i32"
},
{
"name": "n",
"type": "i32"
},
{
"name": "k",
"type": "i32"
}
],
"retur... |
3,427 | sum-of-variable-length-subarrays | Easy | You are given an integer array nums of size n. For each index i where 0 <= i < n, define a subarray nums[start ... i] where start = max(0, i - nums[i]).
Return the total sum of all elements from the subarray defined for each index in the array.
Example 1:
Input: nums = [2,3,1]
Output: 11
Explanation:
i | Subarray |... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == 38\n assert candidate(nums = [50, 25, 50, 25, 50]) == 600\n assert candidate(nums = [10, 5, 2, 3]) == 62\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(nums = [10... | [
"[2,3,1]",
"[3,1,1,2]"
] | [
"The constraints are small, so brute force for each index."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().subarraySum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:51",
"tests_total": 94,
"tests_drop... | rust | {
"raw_signature": "pub fn subarray_sum(nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "subarray_sum",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
3,428 | maximum-and-minimum-sums-of-at-most-size-k-subsequences | Medium | You are given an integer array nums and a positive integer k. Return the sum of the maximum and minimum elements of all subsequences of nums with at most k elements.
Since the answer may be very large, return it modulo 10^9 + 7.
Example 1:
Input: nums = [1,2,3], k = 2
Output: 24
Explanation:
The subsequences of nums... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [7, 8, 9, 10, 11],k = 4) == 540\n assert candidate(nums = [5, 0, 6],k = 1) == 22\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 7007\n assert candidate(nums = [4, 3, 2, 1],k = 3) == 70\n assert can... | [
"[1,2,3]\n2",
"[5,0,6]\n1",
"[1,1,1]\n2"
] | [
"Sort the array."
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().minMaxSums",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:53",
"tests_total": 107,
"t... | rust | {
"raw_signature": "pub fn min_max_sums(nums: Vec<i32>, k: i32) -> i32 {",
"container": "Solution",
"callable": "min_max_sums",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "i32",
"signature_source": "leetc... |
3,429 | paint-house-iv | Medium | You are given an even integer n representing the number of houses arranged in a straight line, and a 2D array cost of size n x 3, where cost[i][j] represents the cost of painting house i with color j + 1.
The houses will look beautiful if they satisfy the following conditions:
- No two adjacent houses are painted the... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 4,cost = [[3, 5, 7], [6, 2, 9], [4, 8, 1], [7, 3, 5]]) == 9\n assert candidate(n = 10,cost = [[5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]]) == 30\n assert candida... | [
"4\n[[3,5,7],[6,2,9],[4,8,1],[7,3,5]]",
"6\n[[2,4,6],[5,3,8],[7,1,9],[4,6,2],[3,5,7],[8,2,4]]"
] | [
"Use dynamic programming to calculate the minimum cost while ensuring that the adjacency and equidistant constraints are satisfied.",
"Try all 9 combinations of colors for equidistant pairs to get the minimum cost."
] | {
"canonical_parameter_names": [
"n",
"cost"
],
"leetcode_dataset_entry_point": "Solution().minCost",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:24:56",
"tests_total": 91,
"tests... | rust | {
"raw_signature": "pub fn min_cost(n: i32, cost: Vec<Vec<i32>>) -> i64 {",
"container": "Solution",
"callable": "min_cost",
"parameters": [
{
"name": "n",
"type": "i32"
},
{
"name": "cost",
"type": "Vec<Vec<i32>>"
}
],
"return_type": "i64",
"signature_source": "lee... |
3,432 | count-partitions-with-even-sum-difference | Easy | You are given an integer array nums of length n.
A partition is defined as an index i where 0 <= i < n - 1, splitting the array into two non-empty subarrays such that:
- Left subarray contains indices [0, i].
- Right subarray contains indices [i + 1, n - 1].
Return the number of partitions where the difference betwe... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [100, 100, 100, 100]) == 3\n assert candidate(nums = [100, 100]) == 1\n assert candidate(nums = [100, 100, 100, 100, 100]) == 4\n assert candidate(nums = [1, 2, 2]) == 0\n assert candidate(nums = [1, 1, 1, 1]) == 3\n ... | [
"[10,10,3,7,6]",
"[1,2,2]",
"[2,4,6,8]"
] | [
"If the parity of the sum is even, the partition is valid; otherwise, there is no partition."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countPartitions",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:01",
"tests_total": 92,
"tests_... | rust | {
"raw_signature": "pub fn count_partitions(nums: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "count_partitions",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
3,433 | count-mentions-per-user | Medium | You are given an integer numberOfUsers representing the total number of users and an array events of size n x 3.
Each events[i] can be either of the following two types:
1. Message Event: ["MESSAGE", "timestamp_i", "mentions_string_i"]
- This event indicates that a set of users was mentioned in a message at timesta... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(numberOfUsers = 1,events = [['MESSAGE', '1', 'id0'], ['MESSAGE', '1', 'HERE'], ['MESSAGE', '1', 'ALL']]) == [3]\n assert candidate(numberOfUsers = 2,events = [['OFFLINE', '10', '0'], ['MESSAGE', '12', 'HERE']]) == [0, 1]\n assert c... | [
"2\n[[\"MESSAGE\",\"10\",\"id1 id0\"],[\"OFFLINE\",\"11\",\"0\"],[\"MESSAGE\",\"71\",\"HERE\"]]",
"2\n[[\"MESSAGE\",\"10\",\"id1 id0\"],[\"OFFLINE\",\"11\",\"0\"],[\"MESSAGE\",\"12\",\"ALL\"]]",
"2\n[[\"OFFLINE\",\"10\",\"0\"],[\"MESSAGE\",\"12\",\"HERE\"]]"
] | [
"Sort events by timestamp and then process each event.",
"Maintain two sets for offline and online user IDs."
] | {
"canonical_parameter_names": [
"numberOfUsers",
"events"
],
"leetcode_dataset_entry_point": "Solution().countMentions",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:04",
"tests_... | rust | {
"raw_signature": "pub fn count_mentions(number_of_users: i32, events: Vec<Vec<String>>) -> Vec<i32> {",
"container": "Solution",
"callable": "count_mentions",
"parameters": [
{
"name": "number_of_users",
"type": "i32"
},
{
"name": "events",
"type": "Vec<Vec<String>>"
}
... |
3,434 | maximum-frequency-after-subarray-operation | Medium | You are given an array nums of length n. You are also given an integer k.
You perform the following operation on nums once:
- Select a subarray nums[i..j] where 0 <= i <= j <= n - 1.
- Select an integer x and add x to all the elements in nums[i..j].
Find the maximum frequency of the value k after the operation.
Exa... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 5\n assert candidate(nums = [10, 20, 30, 40, 50],k = 50) == 2\n assert candidate(nums = [1, 50, 1, 50, 1],k = 50) == 3\n assert candidate(nums = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25],k = 25) =... | [
"[1,2,3,4,5,6]\n1",
"[10,2,3,4,5,5,4,3,2,2]\n10"
] | [
"Fix the element you want to convert to k.",
"Use prefix sums to optimize counting occurrences of an element."
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxFrequency",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:06",
"tests_total": 132,
... | rust | {
"raw_signature": "pub fn max_frequency(nums: Vec<i32>, k: i32) -> i32 {",
"container": "Solution",
"callable": "max_frequency",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "i32",
"signature_source": "lee... |
3,435 | frequencies-of-shortest-supersequences | Hard | You are given an array of strings words. Find all shortest common supersequences (SCS) of words that are not permutations of each other.
A shortest common supersequence is a string of minimum length that contains each string in words as a subsequence.
Return a 2D array of integers freqs that represent all the SCSs. E... | {
"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 ... | [
"[\"ab\",\"ba\"]",
"[\"aa\",\"ac\"]",
"[\"aa\",\"bb\",\"cc\"]"
] | [
"Each SCS contains at most 2 occurrences of each character. Why?",
"Construct every subset of possible characters (1 or 2).",
"Check if a supersequence could be constructed using Topological Sort."
] | {
"canonical_parameter_names": [
"words"
],
"leetcode_dataset_entry_point": "Solution().supersequences",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:08",
"tests_total": 146,
"tests... | rust | {
"raw_signature": "pub fn supersequences(words: Vec<String>) -> Vec<Vec<i32>> {",
"container": "Solution",
"callable": "supersequences",
"parameters": [
{
"name": "words",
"type": "Vec<String>"
}
],
"return_type": "Vec<Vec<i32>>",
"signature_source": "leetcode/codeSnippets",
"type_s... |
3,438 | find-valid-pair-of-adjacent-digits-in-string | Easy | You are given a string s consisting only of digits. A valid pair is defined as two adjacent digits in s such that:
- The first digit is not equal to the second.
- Each digit in the pair appears in s exactly as many times as its numeric value.
Return the first valid pair found in the string s when traversing from left... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"213123\") == \"\"\n assert candidate(s = \"9999999998888888777777666665555444332211\") == \"\"\n assert candidate(s = \"221\") == \"21\"\n assert candidate(s = \"22221111\") == \"\"\n assert candidate(s = \"122223333344... | [
"\"2523533\"",
"\"221\"",
"\"22\""
] | [
"Use a HashMap to count the frequency of each digit."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().findValidPair",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:13",
"tests_total": 166,
"tests_drop... | rust | {
"raw_signature": "pub fn find_valid_pair(s: String) -> String {",
"container": "Solution",
"callable": "find_valid_pair",
"parameters": [
{
"name": "s",
"type": "String"
}
],
"return_type": "String",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
3,439 | reschedule-meetings-for-maximum-free-time-i | Medium | You are given an integer eventTime denoting the duration of an event, where the event occurs from time t = 0 to time t = eventTime.
You are also given two integer arrays startTime and endTime, each of length n. These represent the start and end time of n non-overlapping meetings, where the i^th meeting occurs during t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(eventTime = 15,k = 3,startTime = [1, 5, 9],endTime = [3, 7, 12]) == 8\n assert candidate(eventTime = 10,k = 1,startTime = [0, 2, 9],endTime = [1, 4, 10]) == 6\n assert candidate(eventTime = 5,k = 1,startTime = [1, 3],endTime = [2, ... | [
"5\n1\n[1,3]\n[2,5]",
"10\n1\n[0,2,9]\n[1,4,10]",
"5\n2\n[0,1,2,3,4]\n[1,2,3,4,5]"
] | [
"In a sequence of K meetings and K + 1 gaps, you could move all meetings to the start of the sequence to get the max free time.",
"Use a sliding window of K + 1 size to store sum of gaps and take the maximum."
] | {
"canonical_parameter_names": [
"eventTime",
"k",
"startTime",
"endTime"
],
"leetcode_dataset_entry_point": "Solution().maxFreeTime",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30... | rust | {
"raw_signature": "pub fn max_free_time(event_time: i32, k: i32, start_time: Vec<i32>, end_time: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "max_free_time",
"parameters": [
{
"name": "event_time",
"type": "i32"
},
{
"name": "k",
"type": "i32"
},
{
... |
3,440 | reschedule-meetings-for-maximum-free-time-ii | Medium | You are given an integer eventTime denoting the duration of an event. You are also given two integer arrays startTime and endTime, each of length n.
These represent the start and end times of n non-overlapping meetings that occur during the event between time t = 0 and time t = eventTime, where the i^th meeting occurs... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(eventTime = 50,startTime = [0, 5, 10, 15, 20],endTime = [3, 8, 13, 18, 23]) == 29\n assert candidate(eventTime = 50,startTime = [5, 15, 25, 35],endTime = [10, 20, 30, 40]) == 20\n assert candidate(eventTime = 20,startTime = [0, 5, ... | [
"5\n[1,3]\n[2,5]",
"10\n[0,7,9]\n[1,8,10]",
"10\n[0,3,7,9]\n[1,4,8,10]",
"5\n[0,1,2,3,4]\n[1,2,3,4,5]"
] | [
"If we reschedule a meeting earlier or later, we need to find a gap of length at least endTime[i] - startTime[i]. Try maintaining the gaps in some sorted data structure."
] | {
"canonical_parameter_names": [
"eventTime",
"startTime",
"endTime"
],
"leetcode_dataset_entry_point": "Solution().maxFreeTime",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:18... | rust | {
"raw_signature": "pub fn max_free_time(event_time: i32, start_time: Vec<i32>, end_time: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "max_free_time",
"parameters": [
{
"name": "event_time",
"type": "i32"
},
{
"name": "start_time",
"type": "Vec<i32>"
},
... |
3,441 | minimum-cost-good-caption | Hard | You are given a string caption of length n. A good caption is a string where every character appears in groups of at least 3 consecutive occurrences.
For example:
- "aaabbb" and "aaaaccc" are good captions.
- "aabbb" and "ccccd" are not good captions.
You can perform the following operation any number of times:
Cho... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(caption = \"cdcd\") == \"cccc\"\n assert candidate(caption = \"xyz\") == \"yyy\"\n assert candidate(caption = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aaaaccceeefffhhhiiikkklllnnnoooqqqrrrtttuuuwwwxxxzzz\"\n ... | [
"\"cdcd\"",
"\"aca\"",
"\"bc\""
] | [
"Construct a DP table and try all possible characters at every index.",
"Choose characters greedily to get the lexicographically smallest caption."
] | {
"canonical_parameter_names": [
"caption"
],
"leetcode_dataset_entry_point": "Solution().minCostGoodCaption",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:21",
"tests_total": 80,
"... | rust | {
"raw_signature": "pub fn min_cost_good_caption(caption: String) -> String {",
"container": "Solution",
"callable": "min_cost_good_caption",
"parameters": [
{
"name": "caption",
"type": "String"
}
],
"return_type": "String",
"signature_source": "leetcode/codeSnippets",
"type_source"... |
3,442 | maximum-difference-between-even-and-odd-frequency-i | Easy | You are given a string s consisting of lowercase English letters.
Your task is to find the maximum difference diff = freq(a_1) - freq(a_2) between the frequency of characters a_1 and a_2 in the string such that:
- a_1 has an odd frequency in the string.
- a_2 has an even frequency in the string.
Return this maximum ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abacabadabacaba\") == -1\n assert candidate(s = \"aabbc\") == -1\n assert candidate(s = \"aaabbbcccdddeeefffgghhhiiiijjjjkkkkllllmmmmmnnnnooooo\") == 3\n assert candidate(s = \"aabbccdde\") == -1\n assert candidate(s = ... | [
"\"aaaaabbc\"",
"\"abcabcab\""
] | [
"Use a frequency map to identify the maximum odd and minimum even frequencies. Then, calculate their difference."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().maxDifference",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:23",
"tests_total": 49,
"tests_dropp... | rust | {
"raw_signature": "pub fn max_difference(s: String) -> i32 {",
"container": "Solution",
"callable": "max_difference",
"parameters": [
{
"name": "s",
"type": "String"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,443 | maximum-manhattan-distance-after-k-changes | Medium | You are given a string s consisting of the characters 'N', 'S', 'E', and 'W', where s[i] indicates movements in an infinite grid:
- 'N' : Move north by 1 unit.
- 'S' : Move south by 1 unit.
- 'E' : Move east by 1 unit.
- 'W' : Move west by 1 unit.
Initially, you are at the origin (0, 0). You can change at most k char... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"NSWWEW\",k = 3) == 6\n assert candidate(s = \"EEEEEE\",k = 0) == 6\n assert candidate(s = \"NNN\",k = 0) == 3\n assert candidate(s = \"NWSE\",k = 1) == 3\n assert candidate(s = \"EEEE\",k = 4) == 4\n assert candidate... | [
"\"NWSE\"\n1",
"\"NSWWEW\"\n3"
] | [
"We can brute force all the possible directions (NE, NW, SE, SW).",
"Change up to k characters to maximize the distance in the chosen direction."
] | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxDistance",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:26",
"tests_total": 108,
"tes... | rust | {
"raw_signature": "pub fn max_distance(s: String, k: i32) -> i32 {",
"container": "Solution",
"callable": "max_distance",
"parameters": [
{
"name": "s",
"type": "String"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSn... |
3,444 | minimum-increments-for-target-multiples-in-an-array | Hard | You are given two arrays, nums and target.
In a single operation, you may increment any element of nums by 1.
Return the minimum number of operations required so that each element in target has at least one multiple in nums.
Example 1:
Input: nums = [1,2,3], target = [4]
Output: 1
Explanation:
The minimum number of... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 10, 15],target = [5, 10, 15]) == 0\n assert candidate(nums = [5, 10, 15, 20],target = [5, 15]) == 0\n assert candidate(nums = [10, 20, 30],target = [5, 15]) == 0\n assert candidate(nums = [1, 1, 1],target = [3]) == 2\... | [
"[1,2,3]\n[4]",
"[8,4]\n[10,5]",
"[7,9,10]\n[7]"
] | [
"Use bitmask dynamic programming."
] | {
"canonical_parameter_names": [
"nums",
"target"
],
"leetcode_dataset_entry_point": "Solution().minimumIncrements",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:28",
"tests_total... | rust | {
"raw_signature": "pub fn minimum_increments(nums: Vec<i32>, target: Vec<i32>) -> i32 {",
"container": "Solution",
"callable": "minimum_increments",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "target",
"type": "Vec<i32>"
}
],
"return_type": "i3... |
3,445 | maximum-difference-between-even-and-odd-frequency-ii | Hard | You are given a string s and an integer k. Your task is to find the maximum difference between the frequency of two characters, freq[a] - freq[b], in a substring subs of s, such that:
- subs has a size of at least k.
- Character a has an odd frequency in subs.
- Character b has a non-zero even frequency in subs.
Retu... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"1010101010\",k = 4) == 1\n assert candidate(s = \"000111\",k = 2) == 1\n assert candidate(s = \"101010101\",k = 4) == 1\n assert candidate(s = \"444333222111\",k = 6) == 1\n assert candidate(s = \"111222333\",k = 6) == ... | [
"\"12233\"\n4",
"\"1122211\"\n3",
"\"110\"\n3"
] | [
"Fix the two characters.",
"Use prefix sum (maintain 2 characters' parities as status)."
] | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxDifference",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:30",
"tests_total": 137,
"t... | rust | {
"raw_signature": "pub fn max_difference(s: String, k: i32) -> i32 {",
"container": "Solution",
"callable": "max_difference",
"parameters": [
{
"name": "s",
"type": "String"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "i32",
"signature_source": "leetcode/co... |
3,446 | sort-matrix-by-diagonals | Medium | You are given an n x n square matrix of integers grid. Return the matrix such that:
- The diagonals in the bottom-left triangle (including the middle diagonal) are sorted in non-increasing order.
- The diagonals in the top-right triangle are sorted in non-decreasing order.
Example 1:
Input: grid = [[1,7,3],[9,8,2],[... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[5, 2, 9], [8, 3, 6], [1, 4, 7]]) == [[7, 2, 9], [8, 5, 6], [1, 4, 3]]\n assert candidate(grid = [[0, 1], [1, 2]]) == [[2, 1], [1, 0]]\n assert candidate(grid = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == [[9, 4, 7], [6, 5, 8], [... | [
"[[1,7,3],[9,8,2],[4,5,6]]",
"[[0,1],[1,2]]",
"[[1]]"
] | [
"Use a data structure to store all values in each diagonal.",
"Sort and replace them in the matrix."
] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().sortMatrix",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:32",
"tests_total": 79,
"tests_dropp... | rust | {
"raw_signature": "pub fn sort_matrix(grid: Vec<Vec<i32>>) -> Vec<Vec<i32>> {",
"container": "Solution",
"callable": "sort_matrix",
"parameters": [
{
"name": "grid",
"type": "Vec<Vec<i32>>"
}
],
"return_type": "Vec<Vec<i32>>",
"signature_source": "leetcode/codeSnippets",
"type_sourc... |
3,447 | assign-elements-to-groups-with-constraints | Medium | You are given an integer array groups, where groups[i] represents the size of the i^th group. You are also given an integer array elements.
Your task is to assign one element to each group based on the following rules:
- An element at index j can be assigned to a group i if groups[i] is divisible by elements[j].
- If... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(groups = [1, 1, 1, 1, 1],elements = [1]) == [0, 0, 0, 0, 0]\n assert candidate(groups = [10, 10, 10, 10],elements = [5, 10]) == [0, 0, 0, 0]\n assert candidate(groups = [11, 22, 33, 44, 55],elements = [11, 22]) == [0, 0, 0, 0, 0]\n... | [
"[8,4,3,2,4]\n[4,2]",
"[2,3,5,7]\n[5,3,3]",
"[10,21,30,41]\n[2,1]"
] | [
"Can a sieve-like approach be applied here?",
"Starting from the smallest index, iterate through the multiples of the element and assign it to groups divisible by that value.",
"Process each element once.",
"Find all divisors of each group, then match them with elements."
] | {
"canonical_parameter_names": [
"groups",
"elements"
],
"leetcode_dataset_entry_point": "Solution().assignElements",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:36",
"tests_tota... | rust | {
"raw_signature": "pub fn assign_elements(groups: Vec<i32>, elements: Vec<i32>) -> Vec<i32> {",
"container": "Solution",
"callable": "assign_elements",
"parameters": [
{
"name": "groups",
"type": "Vec<i32>"
},
{
"name": "elements",
"type": "Vec<i32>"
}
],
"return_typ... |
3,448 | count-substrings-divisible-by-last-digit | Hard | You are given a string s consisting of digits.
Return the number of substrings of s divisible by their non-zero last digit.
Note: A substring may contain leading zeros.
Example 1:
Input: s = "12936"
Output: 11
Explanation:
Substrings "29", "129", "293" and "2936" are not divisible by their last digit. There are 15 ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"24680\") == 6\n assert candidate(s = \"11111\") == 15\n assert candidate(s = \"5701283\") == 18\n assert candidate(s = \"9876543210\") == 35\n assert candidate(s = \"1001001001\") == 22\n assert candidate(s = \"99999... | [
"\"12936\"",
"\"5701283\"",
"\"1010101010\""
] | [
"Let dp[index][i][j] be the number of subarrays s[start...index] such that s[start...index] % i == j.",
"For every pair (i, j), add dp[index - 1][i][j] to dp[index][i][(j * 10 + x)%i)].",
"You should optimize this solution so that it can fit into the memory limit.",
"In order to find dp[index][i][j] we use va... | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().countSubstrings",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:38",
"tests_total": 113,
"tests_dr... | rust | {
"raw_signature": "pub fn count_substrings(s: String) -> i64 {",
"container": "Solution",
"callable": "count_substrings",
"parameters": [
{
"name": "s",
"type": "String"
}
],
"return_type": "i64",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,449 | maximize-the-minimum-game-score | Hard | You are given an array points of size n and an integer m. There is another array gameScore of size n, where gameScore[i] represents the score achieved at the i^th game. Initially, gameScore[i] == 0 for all i.
You start at index -1, which is outside the array (before the first position at index 0). You can make at most... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(points = [5, 3, 8, 2, 6],m = 10) == 6\n assert candidate(points = [5, 9, 3, 7],m = 7) == 6\n assert candidate(points = [1, 1, 1, 1, 1],m = 5) == 1\n assert candidate(points = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 20) == 2\n asse... | [
"[2,4]\n3",
"[1,2,3]\n5"
] | [
"Can we use binary search?",
"What happens if you fix the game score as x?",
"We should go from i to (i + 1) back and forth, making the value for each index i (from left to right) no less than x."
] | {
"canonical_parameter_names": [
"points",
"m"
],
"leetcode_dataset_entry_point": "Solution().maxScore",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:41",
"tests_total": 95,
"te... | rust | {
"raw_signature": "pub fn max_score(points: Vec<i32>, m: i32) -> i64 {",
"container": "Solution",
"callable": "max_score",
"parameters": [
{
"name": "points",
"type": "Vec<i32>"
},
{
"name": "m",
"type": "i32"
}
],
"return_type": "i64",
"signature_source": "leetcod... |
3,452 | sum-of-good-numbers | Easy | Given an array of integers nums and an integer k, an element nums[i] is considered good if it is strictly greater than the elements at indices i - k and i + k (if those indices exist). If neither of these indices exists, nums[i] is still considered good.
Return the sum of all the good elements in the array.
Example 1... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [2, 1],k = 1) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 2) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],... | [
"[1,3,2,1,5,4]\n2",
"[2,1]\n1"
] | [
"For each index, check if nums[i] is strictly greater than nums[i - k] and nums[i + k]."
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().sumOfGoodNumbers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:45",
"tests_total": 109... | rust | {
"raw_signature": "pub fn sum_of_good_numbers(nums: Vec<i32>, k: i32) -> i32 {",
"container": "Solution",
"callable": "sum_of_good_numbers",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "i32",
"signature_s... |
3,453 | separate-squares-i | Medium | You are given a 2D integer array squares. Each squares[i] = [x_i, y_i, l_i] represents the coordinates of the bottom-left point and the side length of a square parallel to the x-axis.
Find the minimum y-coordinate value of a horizontal line such that the total area of the squares above the line equals the total area o... | {
"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... | [
"[[0,0,1],[2,2,1]]",
"[[0,0,2],[1,1,1]]"
] | [
"Binary search on the answer."
] | {
"canonical_parameter_names": [
"squares"
],
"leetcode_dataset_entry_point": "Solution().separateSquares",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:48",
"tests_total": 107,
"te... | rust | {
"raw_signature": "pub fn separate_squares(squares: Vec<Vec<i32>>) -> f64 {",
"container": "Solution",
"callable": "separate_squares",
"parameters": [
{
"name": "squares",
"type": "Vec<Vec<i32>>"
}
],
"return_type": "f64",
"signature_source": "leetcode/codeSnippets",
"type_source": ... |
3,454 | separate-squares-ii | Hard | You are given a 2D integer array squares. Each squares[i] = [x_i, y_i, l_i] represents the coordinates of the bottom-left point and the side length of a square parallel to the x-axis.
Find the minimum y-coordinate value of a horizontal line such that the total area covered by squares above the line equals the total ar... | {
"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... | [
"[[0,0,1],[2,2,1]]",
"[[0,0,2],[1,1,1]]"
] | [
"Use a line sweep and a segment tree.",
"The line must lie in one of the squares."
] | {
"canonical_parameter_names": [
"squares"
],
"leetcode_dataset_entry_point": "Solution().separateSquares",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:51",
"tests_total": 103,
"te... | rust | {
"raw_signature": "pub fn separate_squares(squares: Vec<Vec<i32>>) -> f64 {",
"container": "Solution",
"callable": "separate_squares",
"parameters": [
{
"name": "squares",
"type": "Vec<Vec<i32>>"
}
],
"return_type": "f64",
"signature_source": "leetcode/codeSnippets",
"type_source": ... |
3,455 | shortest-matching-substring | Hard | You are given a string s and a pattern string p, where p contains exactly two '*' characters.
The '*' in p matches any sequence of zero or more characters.
Return the length of the shortest substring in s that matches p. If there is no such substring, return -1.
Note: The empty substring is considered valid.
Exampl... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abcdefg\",p = \"*bcd*fg\") == 6\n assert candidate(s = \"abcabcabc\",p = \"*bc*bc\") == 5\n assert candidate(s = \"mississippi\",p = \"mis*si*\") == 5\n assert candidate(s = \"baccbaadbc\",p = \"cc*baa*adb\") == -1\n as... | [
"\"abaacbaecebce\"\n\"ba*c*ce\"",
"\"baccbaadbc\"\n\"cc*baa*adb\"",
"\"a\"\n\"**\"",
"\"madlogic\"\n\"*adlogi*\""
] | [
"The pattern string p can be divided into three segments.",
"Use the KMP algorithm to locate all occurrences of each segment in s."
] | {
"canonical_parameter_names": [
"s",
"p"
],
"leetcode_dataset_entry_point": "Solution().shortestMatchingSubstring",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:53",
"tests_total... | rust | {
"raw_signature": "pub fn shortest_matching_substring(s: String, p: String) -> i32 {",
"container": "Solution",
"callable": "shortest_matching_substring",
"parameters": [
{
"name": "s",
"type": "String"
},
{
"name": "p",
"type": "String"
}
],
"return_type": "i32",
... |
3,456 | find-special-substring-of-length-k | Easy | You are given a string s and an integer k.
Determine if there exists a substring of length exactly k in s that satisfies the following conditions:
1. The substring consists of only one distinct character (e.g., "aaa" or "bbb").
2. If there is a character immediately before the substring, it must be different from the... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abc\",k = 2) == False\n assert candidate(s = \"aabbccddeeff\",k = 2) == True\n assert candidate(s = \"abcde\",k = 1) == True\n assert candidate(s = \"zzzz\",k = 4) == True\n assert candidate(s = \"xyzxyz\",k = 1) == Tru... | [
"\"aaabaaa\"\n3",
"\"abc\"\n2"
] | [
"Return true if there is a sequence of consecutive characters of length k"
] | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().hasSpecialSubstring",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:56",
"tests_total": 111... | rust | {
"raw_signature": "pub fn has_special_substring(s: String, k: i32) -> bool {",
"container": "Solution",
"callable": "has_special_substring",
"parameters": [
{
"name": "s",
"type": "String"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "bool",
"signature_sourc... |
3,457 | eat-pizzas | Medium | You are given an integer array pizzas of size n, where pizzas[i] represents the weight of the i^th pizza. Every day, you eat exactly 4 pizzas. Due to your incredible metabolism, when you eat pizzas of weights W, X, Y, and Z, where W <= X <= Y <= Z, you gain the weight of only 1 pizza!
- On odd-numbered days (1-indexed... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(pizzas = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 320\n assert candidate(pizzas = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(pizzas = [1, 3, 2, 4, 7, 6, 9, 8, 13, 12, 11, 10, 15, 14, 1... | [
"[1,2,3,4,5,6,7,8]",
"[2,1,1,1,1,1,1,1]"
] | [
"On odd-numbered days, it is optimal to pair the smallest three and the largest one.",
"On even-numbered days, it is optimal to pair the smallest two and the largest two.",
"There will be ceil((n / 4) / 2) odd-numbered days. Select pizzas for all odd-numbered days first.",
"Select the remaining pizzas for the... | {
"canonical_parameter_names": [
"pizzas"
],
"leetcode_dataset_entry_point": "Solution().maxWeight",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:25:58",
"tests_total": 103,
"tests_dro... | rust | {
"raw_signature": "pub fn max_weight(pizzas: Vec<i32>) -> i64 {",
"container": "Solution",
"callable": "max_weight",
"parameters": [
{
"name": "pizzas",
"type": "Vec<i32>"
}
],
"return_type": "i64",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
3,458 | select-k-disjoint-special-substrings | Medium | Given a string s of length n and an integer k, determine whether it is possible to select k disjoint special substrings.
A special substring is a substring where:
- Any character present inside the substring should not appear outside it in the string.
- The substring is not the entire string s.
Note that all k subst... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"single\",k = 0) == True\n assert candidate(s = \"abeabe\",k = 0) == True\n assert candidate(s = \"cdefdc\",k = 3) == False\n assert candidate(s = \"abacabadabacaba\",k = 3) == False\n assert candidate(s = \"aabbccddeeff... | [
"\"abcdbaefab\"\n2",
"\"cdefdc\"\n3",
"\"abeabe\"\n0"
] | [
"There are at most 26 start points (which are the first occurrence of each letter) and at most 26 end points (which are the last occurrence of each letter) of the substring.",
"Starting from each character, build the smallest special substring interval containing it.",
"Use dynamic programming on the obtained i... | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxSubstringLength",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:26:00",
"tests_total": 95,
... | rust | {
"raw_signature": "pub fn max_substring_length(s: String, k: i32) -> bool {",
"container": "Solution",
"callable": "max_substring_length",
"parameters": [
{
"name": "s",
"type": "String"
},
{
"name": "k",
"type": "i32"
}
],
"return_type": "bool",
"signature_source"... |
3,459 | length-of-longest-v-shaped-diagonal-segment | Hard | You are given a 2D integer matrix grid of size n x m, where each element is either 0, 1, or 2.
A V-shaped diagonal segment is defined as:
- The segment starts with 1.
- The subsequent elements follow this infinite sequence: 2, 0, 2, 0, ....
- The segment:
- Starts along a diagonal direction (top-left to bottom-righ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 1\n assert candidate(grid = [[1, 2, 0, 2, 0, 1, 2], [0, 2, 1, 2, 1, 2, 2], [0, 0, 2, 1, 2, 1, 2], [2, 0, 2, 1, 2, 1, 0]]) == 3\n assert candidate(grid = [[2, 0, 0, 0], [1, 2, 2, 2], [0, ... | [
"[[2,2,1,2,2],[2,0,2,2,0],[2,0,1,1,0],[1,0,2,2,2],[2,0,0,2,2]]",
"[[2,2,2,2,2],[2,0,2,2,0],[2,0,1,1,0],[1,0,2,2,2],[2,0,0,2,2]]",
"[[1,2,2,2,2],[2,2,2,2,0],[2,0,0,0,0],[0,0,2,2,2],[2,0,0,2,0]]",
"[[1]]"
] | [
"Use dynamic programming to determine the best point to make a 90-degree rotation in the diagonal path while maintaining the required sequence.",
"Represent dynamic programming states as (row, col, currentDirection, hasMadeTurnYet). Track the current position, direction of traversal, and whether a turn has alread... | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().lenOfVDiagonal",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:26:03",
"tests_total": 76,
"tests_d... | rust | {
"raw_signature": "pub fn len_of_v_diagonal(grid: Vec<Vec<i32>>) -> i32 {",
"container": "Solution",
"callable": "len_of_v_diagonal",
"parameters": [
{
"name": "grid",
"type": "Vec<Vec<i32>>"
}
],
"return_type": "i32",
"signature_source": "leetcode/codeSnippets",
"type_source": "lee... |
3,461 | check-if-digits-are-equal-in-string-after-operations-i | Easy | You are given a string s consisting of digits. Perform the following operation repeatedly until the string has exactly two digits:
- For each pair of consecutive digits in s, starting from the first digit, calculate a new digit as the sum of the two digits modulo 10.
- Replace s with the sequence of newly calculated d... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"9876543210\") == False\n assert candidate(s = \"100100\") == False\n assert candidate(s = \"123321\") == True\n assert candidate(s = \"111\") == True\n assert candidate(s = \"1234567890\") == False\n assert candidate... | [
"\"3902\"",
"\"34789\""
] | [
"Simulate the operations as described."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().hasSameDigits",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:26:07",
"tests_total": 127,
"tests_drop... | rust | {
"raw_signature": "pub fn has_same_digits(s: String) -> bool {",
"container": "Solution",
"callable": "has_same_digits",
"parameters": [
{
"name": "s",
"type": "String"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,462 | maximum-sum-with-at-most-k-elements | Medium | You are given a 2D integer matrix grid of size n x m, an integer array limits of length n, and an integer k. The task is to find the maximum sum of at most k elements from the matrix grid such that:
-
The number of elements taken from the i^th row of grid does not exceed limits[i].
Return the maximum sum.
Example 1:... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[10, 20, 30], [5, 15, 25], [1, 9, 18]],limits = [2, 1, 2],k = 5) == 102\n assert candidate(grid = [[5, 3, 7], [8, 2, 6]],limits = [2, 2],k = 3) == 21\n assert candidate(grid = [[1, 2], [3, 4]],limits = [1, 2],k = 2) == 7\n ... | [
"[[1,2],[3,4]]\n[1,2]\n2",
"[[5,3,7],[8,2,6]]\n[2,2]\n3"
] | [
"Sort each row in descending order and extract the top limits[i] elements.",
"Use a max-heap to efficiently pick the largest k elements across all rows."
] | {
"canonical_parameter_names": [
"grid",
"limits",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:26:10",
"tests_total":... | rust | {
"raw_signature": "pub fn max_sum(grid: Vec<Vec<i32>>, limits: Vec<i32>, k: i32) -> i64 {",
"container": "Solution",
"callable": "max_sum",
"parameters": [
{
"name": "grid",
"type": "Vec<Vec<i32>>"
},
{
"name": "limits",
"type": "Vec<i32>"
},
{
"name": "k",
... |
3,463 | check-if-digits-are-equal-in-string-after-operations-ii | Hard | You are given a string s consisting of digits. Perform the following operation repeatedly until the string has exactly two digits:
- For each pair of consecutive digits in s, starting from the first digit, calculate a new digit as the sum of the two digits modulo 10.
- Replace s with the sequence of newly calculated d... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"9876543210\") == False\n assert candidate(s = \"111\") == True\n assert candidate(s = \"1234567890\") == False\n assert candidate(s = \"898989898\") == True\n assert candidate(s = \"1111111111\") == True\n assert can... | [
"\"3902\"",
"\"34789\""
] | [
"Can we use nCr and use Pascal's triangle values here?",
"nCr mod 10 can be uniquely determined from nCr mod 2 and nCr mod 5.",
"Use Lucas's theorem."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().hasSameDigits",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:26:12",
"tests_total": 108,
"tests_drop... | rust | {
"raw_signature": "pub fn has_same_digits(s: String) -> bool {",
"container": "Solution",
"callable": "has_same_digits",
"parameters": [
{
"name": "s",
"type": "String"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,464 | maximize-the-distance-between-points-on-a-square | Hard | You are given an integer side, representing the edge length of a square with corners at (0, 0), (0, side), (side, 0), and (side, side) on a Cartesian plane.
You are also given a positive integer k and a 2D integer array points, where points[i] = [x_i, y_i] represents the coordinate of a point lying on the boundary of ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(side = 4,points = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [4, 3], [4, 2], [4, 1], [4, 0], [3, 0], [2, 0], [1, 0]],k = 8) == 2\n assert candidate(side = 3,points = [[0, 0], [0, 1], [0, 2], [0, 3], [3, 0... | [
"2\n[[0,2],[2,0],[2,2],[0,0]]\n4",
"2\n[[0,0],[1,2],[2,0],[2,2],[2,1]]\n4",
"2\n[[0,0],[0,1],[0,2],[1,2],[2,0],[2,2],[2,1]]\n5"
] | [
"Can we use binary search for this problem?",
"Think of the coordinates on a straight line in clockwise order.",
"Binary search on the minimum Manhattan distance x.",
"During the binary search, for each coordinate, find the immediate next coordinate with distance >= x.",
"Greedily select up to k coordinates... | {
"canonical_parameter_names": [
"side",
"points",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxDistance",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:26:14",
"tests_to... | rust | {
"raw_signature": "pub fn max_distance(side: i32, points: Vec<Vec<i32>>, k: i32) -> i32 {",
"container": "Solution",
"callable": "max_distance",
"parameters": [
{
"name": "side",
"type": "i32"
},
{
"name": "points",
"type": "Vec<Vec<i32>>"
},
{
"name": "k",
... |
3,467 | transform-array-by-parity | Easy | You are given an integer array nums. Transform nums by performing the following operations in the exact order specified:
1. Replace each even number with 0.
2. Replace each odd numbers with 1.
3. Sort the modified array in non-decreasing order.
Return the resulting array after performing these operations.
Example 1:... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == [0, 0, 0, 0, 1, 1, 1, 1, 1]\n assert candidate(nums = [4, 3, 2, 1]) == [0, 0, 1, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 0, 0, 0, 0, 1, 1, 1, 1, ... | [
"[4,3,2,1]",
"[1,5,1,4,2]"
] | [
"Let x be the number of even numbers, and y be the number of odd numbers. Output 0 x times, followed by 1 y times."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().transformArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:26:20",
"tests_total": 104,
"tests_... | rust | {
"raw_signature": "pub fn transform_array(nums: Vec<i32>) -> Vec<i32> {",
"container": "Solution",
"callable": "transform_array",
"parameters": [
{
"name": "nums",
"type": "Vec<i32>"
}
],
"return_type": "Vec<i32>",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcod... |
3,468 | find-the-number-of-copy-arrays | Medium | You are given an array original of length n and a 2D array bounds of length n x 2, where bounds[i] = [u_i, v_i].
You need to find the number of possible arrays copy of length n such that:
1. (copy[i] - copy[i - 1]) == (original[i] - original[i - 1]) for 1 <= i <= n - 1.
2. u_i <= copy[i] <= v_i for 0 <= i <= n - 1.
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(original = [1, 2, 3, 4],bounds = [[1, 10], [2, 9], [3, 8], [4, 7]]) == 4\n assert candidate(original = [3, 5, 7, 9],bounds = [[2, 4], [4, 6], [6, 8], [8, 10]]) == 3\n assert candidate(original = [10, 11, 12, 13],bounds = [[8, 10], ... | [
"[1,2,3,4]\n[[1,2],[2,3],[3,4],[4,5]]",
"[1,2,3,4]\n[[1,10],[2,9],[3,8],[4,7]]",
"[1,2,1,2]\n[[1,1],[2,3],[3,3],[2,3]]"
] | [
"copy[0] uniquely determines all other values.",
"Possible values for copy[0] are in [u[0], v[0]].",
"From left to right, compute valid ranges for each index by intersecting bounds with the previous range.",
"The answer is the size of the valid range for the last index."
] | {
"canonical_parameter_names": [
"original",
"bounds"
],
"leetcode_dataset_entry_point": "Solution().countArrays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:26:23",
"tests_total":... | rust | {
"raw_signature": "pub fn count_arrays(original: Vec<i32>, bounds: Vec<Vec<i32>>) -> i32 {",
"container": "Solution",
"callable": "count_arrays",
"parameters": [
{
"name": "original",
"type": "Vec<i32>"
},
{
"name": "bounds",
"type": "Vec<Vec<i32>>"
}
],
"return_type... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.