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,480 | maximize-subarrays-after-removing-one-conflicting-pair | Hard | You are given an integer n which represents an array nums containing the numbers from 1 to n in order. Additionally, you are given a 2D array conflictingPairs, where conflictingPairs[i] = [a, b] indicates that a and b form a conflicting pair.
Remove exactly one element from conflictingPairs. Afterward, count the numbe... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 7,conflictingPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 8\n assert candidate(n = 6,conflictingPairs = [[1, 3], [2, 4], [3, 5], [4, 6]]) == 12\n assert candidate(n = 6,conflictingPairs = [[1, 3], [3, 5], [2, 4]... | [
"4\n[[2,3],[1,4]]",
"5\n[[1,2],[2,5],[3,5]]"
] | [
"Let f[i] (where i = 1, 2, 3, ..., n) be the end index of the longest valid subarray (without any conflicting pair) starting at index i.",
"The answer is: sigma(f[i] - i + 1) for i in [1..n], which simplifies to: sigma(f[i]) - n * (n + 1) / 2 + n.",
"Focus on maintaining f[i].",
"If we have a conflicting pair... | {
"canonical_parameter_names": [
"n",
"conflictingPairs"
],
"leetcode_dataset_entry_point": "Solution().maxSubarrays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:26:49",
"tests_tot... | typescript | {
"raw_signature": "function maxSubarrays(n: number, conflictingPairs: number[][]): number {",
"container": null,
"callable": "maxSubarrays",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "conflictingPairs",
"type": "number[][]"
}
],
"return_type": "num... |
3,483 | unique-3-digit-even-numbers | Easy | You are given an array of digits called digits. Your task is to determine the number of distinct three-digit even numbers that can be formed using these digits.
Note: Each copy of a digit can only be used once per number, and there may not be leading zeros.
Example 1:
Input: digits = [1,2,3,4]
Output: 12
Explanation... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(digits = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 1\n assert candidate(digits = [6, 6, 6]) == 1\n assert candidate(digits = [1, 3, 5]) == 0\n assert candidate(digits ... | [
"[1,2,3,4]",
"[0,2,2]",
"[6,6,6]",
"[1,3,5]"
] | [
"Use brute force to try all possibilities"
] | {
"canonical_parameter_names": [
"digits"
],
"leetcode_dataset_entry_point": "Solution().totalNumbers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:26:53",
"tests_total": 128,
"tests_... | typescript | {
"raw_signature": "function totalNumbers(digits: number[]): number {",
"container": null,
"callable": "totalNumbers",
"parameters": [
{
"name": "digits",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
3,485 | longest-common-prefix-of-k-strings-after-removal | Hard | You are given an array of strings words and an integer k.
For each index i in the range [0, words.length - 1], find the length of the longest common prefix among any k strings (selected at distinct indices) from the remaining array after removing the i^th element.
Return an array answer, where answer[i] is the answer... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(words = ['banana', 'band', 'bend', 'bendy'],k = 3) == [1, 1, 1, 1]\n assert candidate(words = ['abcd', 'abce', 'abcf', 'abcg'],k = 2) == [3, 3, 3, 3]\n assert candidate(words = ['apple', 'application', 'aptitude', 'appetite'],k = 3... | [
"[\"jump\",\"run\",\"run\",\"jump\",\"run\"]\n2",
"[\"dog\",\"racer\",\"car\"]\n2"
] | [
"Use a trie to store all the strings initially.",
"For each node in the trie, maintain the count of paths ending there.",
"For each arr[i], remove it from the trie and update the counts.",
"During evaluation, find the innermost node with at least k paths ending there.",
"Use a multiset or similar structure ... | {
"canonical_parameter_names": [
"words",
"k"
],
"leetcode_dataset_entry_point": "Solution().longestCommonPrefix",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:26:56",
"tests_total":... | typescript | {
"raw_signature": "function longestCommonPrefix(words: string[], k: number): number[] {",
"container": null,
"callable": "longestCommonPrefix",
"parameters": [
{
"name": "words",
"type": "string[]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "number[]",
... |
3,487 | maximum-unique-subarray-sum-after-deletion | Easy | You are given an integer array nums.
You are allowed to delete any number of elements from nums without making it empty. After performing the deletions, select a subarray of nums such that:
1. All elements in the subarray are unique.
2. The sum of the elements in the subarray is maximized.
Return the maximum sum of ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [-1, 2, -3, 4, -5]) == 6\n assert candidate(nums = [-10, 1, 20, -30, 40, -50, 60]) == 121\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 1\n assert ... | [
"[1,2,3,4,5]",
"[1,1,0,1,1]",
"[1,2,-1,-2,1,0,-1]"
] | [
"If the maximum element in the array is less than zero, the answer is the maximum element.",
"Otherwise, the answer is the sum of all unique values that are greater than or equal to zero."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maxSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:00",
"tests_total": 121,
"tests_dropped"... | typescript | {
"raw_signature": "function maxSum(nums: number[]): number {",
"container": null,
"callable": "maxSum",
"parameters": [
{
"name": "nums",
"type": "number[]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,488 | closest-equal-element-queries | Medium | You are given a circular array nums and an array queries.
For each query i, you have to find the following:
- The minimum distance between the element at index queries[i] and any other index j in the circular array, where nums[j] == nums[queries[i]]. If no such index exists, the answer for that query should be -1.
R... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 3, 1, 4, 1, 3, 2],queries = [0, 3, 5]) == [2, -1, 3]\n assert candidate(nums = [1, 2, 3, 4],queries = [0, 1, 2, 3]) == [-1, -1, -1, -1]\n assert candidate(nums = [1000000, 1000000, 1000000],queries = [0, 1, 2]) == [1, 1,... | [
"[1,3,1,4,1,3,2]\n[0,3,5]",
"[1,2,3,4]\n[0,1,2,3]"
] | [
"Use a dictionary that maps each unique value in the array to a sorted list of its indices.",
"For each query, use binary search on the sorted indices list to find the nearest occurrences of the target value."
] | {
"canonical_parameter_names": [
"nums",
"queries"
],
"leetcode_dataset_entry_point": "Solution().solveQueries",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:03",
"tests_total": 9... | typescript | {
"raw_signature": "function solveQueries(nums: number[], queries: number[]): number[] {",
"container": null,
"callable": "solveQueries",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "queries",
"type": "number[]"
}
],
"return_type": "number[]",
... |
3,489 | zero-array-transformation-iv | 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:
- Select a subset of indices in the range [l_i, r_i] from nums.
- Decrement the value at each selected index by exactly val_i.
A Zero Array is an arra... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 2, 6],queries = [[0, 1, 1], [0, 2, 1], [1, 4, 2], [4, 4, 4], [3, 4, 1], [4, 4, 5]]) == 4\n assert candidate(nums = [2, 0, 2],queries = [[0, 2, 1], [0, 2, 1], [1, 1, 3]]) == 2\n assert candidate(nums = [1, 2, 3, 2, ... | [
"[2,0,2]\n[[0,2,1],[0,2,1],[1,1,3]]",
"[4,3,2,1]\n[[1,3,2],[0,2,1]]",
"[1,2,3,2,1]\n[[0,1,1],[1,2,1],[2,3,2],[3,4,1],[4,4,1]]",
"[1,2,3,2,6]\n[[0,1,1],[0,2,1],[1,4,2],[4,4,4],[3,4,1],[4,4,5]]"
] | [
"Use dynamic programming.",
"For each nums[i], use DP to check whether the queries[.][2] values (i.e., the val values) of the queries that affect it can form a combination with a sum equal to nums[i]."
] | {
"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:27:06",
"tests_total": 1... | typescript | {
"raw_signature": "function minZeroArray(nums: number[], queries: number[][]): number {",
"container": null,
"callable": "minZeroArray",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "queries",
"type": "number[][]"
}
],
"return_type": "number",
... |
3,490 | count-beautiful-numbers | Hard | You are given two positive integers, l and r. A positive integer is called beautiful if the product of its digits is divisible by the sum of its digits.
Return the count of beautiful numbers between l and r, inclusive.
Example 1:
Input: l = 10, r = 20
Output: 2
Explanation:
The beautiful numbers in the range are 10 ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(l = 999,r = 999) == 1\n assert candidate(l = 1,r = 9) == 9\n assert candidate(l = 900,r = 1000) == 35\n assert candidate(l = 789,r = 890) == 35\n assert candidate(l = 500,r = 5000) == 1800\n assert candidate(l = 5,r = 50) ... | [
"10\n20",
"1\n15"
] | [
"Use digit dynamic programming."
] | {
"canonical_parameter_names": [
"l",
"r"
],
"leetcode_dataset_entry_point": "Solution().beautifulNumbers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:08",
"tests_total": 92,
... | typescript | {
"raw_signature": "function beautifulNumbers(l: number, r: number): number {",
"container": null,
"callable": "beautifulNumbers",
"parameters": [
{
"name": "l",
"type": "number"
},
{
"name": "r",
"type": "number"
}
],
"return_type": "number",
"signature_source": "l... |
3,492 | maximum-containers-on-a-ship | Easy | You are given a positive integer n representing an n x n cargo deck on a ship. Each cell on the deck can hold one container with a weight of exactly w.
However, the total weight of all containers, if loaded onto the deck, must not exceed the ship's maximum weight capacity, maxWeight.
Return the maximum number of cont... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 10,w = 5,maxWeight = 25) == 5\n assert candidate(n = 10,w = 1,maxWeight = 10) == 10\n assert candidate(n = 5,w = 2,maxWeight = 20) == 10\n assert candidate(n = 5,w = 10,maxWeight = 50) == 5\n assert candidate(n = 5,w = 10... | [
"2\n3\n15",
"3\n5\n20"
] | [
"What are the limits on the number of containers?",
"We can load at most min(n * n, maxWeight / w) containers."
] | {
"canonical_parameter_names": [
"n",
"w",
"maxWeight"
],
"leetcode_dataset_entry_point": "Solution().maxContainers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:12",
"tests_... | typescript | {
"raw_signature": "function maxContainers(n: number, w: number, maxWeight: number): number {",
"container": null,
"callable": "maxContainers",
"parameters": [
{
"name": "n",
"type": "number"
},
{
"name": "w",
"type": "number"
},
{
"name": "maxWeight",
"ty... |
3,493 | properties-graph | Medium | You are given a 2D integer array properties having dimensions n x m and an integer k.
Define a function intersect(a, b) that returns the number of distinct integers common to both arrays a and b.
Construct an undirected graph where each index i corresponds to properties[i]. There is an edge between node i and node j ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(properties = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]],k = 3) == 1\n assert candidate(properties = [[10, 20, 30], [30, 40, 50], [40, 50, 60], [50, 60, 70]],k = 1) == 1\n assert candidate(properties = [[1, 1, 1, 1], [... | [
"[[1,2],[1,1],[3,4],[4,5],[5,6],[7,7]]\n1",
"[[1,2,3],[2,3,4],[4,3,5]]\n2",
"[[1,1],[1,1]]\n2"
] | [
"How can we optimally find the intersection of two arrays? One way is to use len(set(a) & set(b)).",
"For connected components, think about using DFS, BFS, or DSU."
] | {
"canonical_parameter_names": [
"properties",
"k"
],
"leetcode_dataset_entry_point": "Solution().numberOfComponents",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:15",
"tests_tot... | typescript | {
"raw_signature": "function numberOfComponents(properties: number[][], k: number): number {",
"container": null,
"callable": "numberOfComponents",
"parameters": [
{
"name": "properties",
"type": "number[][]"
},
{
"name": "k",
"type": "number"
}
],
"return_type": "num... |
3,494 | find-the-minimum-amount-of-time-to-brew-potions | Medium | You are given two integer arrays, skill and mana, of length n and m, respectively.
In a laboratory, n wizards must brew m potions in order. Each potion has a mana capacity mana[j] and must pass through all the wizards sequentially to be brewed properly. The time taken by the i^th wizard on the j^th potion is time_ij =... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(skill = [10, 20, 30],mana = [1, 2, 3, 4, 5]) == 490\n assert candidate(skill = [3, 2, 1],mana = [6, 5, 4]) == 57\n assert candidate(skill = [1, 1, 1],mana = [1, 1, 1]) == 5\n assert candidate(skill = [1, 2, 3],mana = [4, 5, 6, 7... | [
"[1,5,2,4]\n[5,1,4,2]",
"[1,1,1]\n[1,1,1]",
"[1,2,3,4]\n[1,2]"
] | [
"Maintain each wizard's earliest free time (for the last potion) as f[i].",
"Let x be the current mana value. Starting from now = f[0], update now = max(now + skill[i - 1] * x, f[i]) for i in [1..n]. Then, the final f[n - 1] = now + skill[n - 1] * x for this potion.",
"Update all other f values by f[i] = f[i + ... | {
"canonical_parameter_names": [
"skill",
"mana"
],
"leetcode_dataset_entry_point": "Solution().minTime",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:17",
"tests_total": 103,
"... | typescript | {
"raw_signature": "function minTime(skill: number[], mana: number[]): number {",
"container": null,
"callable": "minTime",
"parameters": [
{
"name": "skill",
"type": "number[]"
},
{
"name": "mana",
"type": "number[]"
}
],
"return_type": "number",
"signature_source"... |
3,495 | minimum-operations-to-make-array-elements-zero | Hard | You are given a 2D array queries, where queries[i] is of the form [l, r]. Each queries[i] defines an array of integers nums consisting of elements ranging from l to r, both inclusive.
In one operation, you can:
- Select two integers a and b from the array.
- Replace them with floor(a / 4) and floor(b / 4).
Your task... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(queries = [[1, 2], [2, 4]]) == 3\n assert candidate(queries = [[10, 20], [20, 30], [30, 40]]) == 48\n assert candidate(queries = [[1, 1000000000], [500000000, 1000000000]]) == 11071043045\n assert candidate(queries = [[1, 100], ... | [
"[[1,2],[2,4]]",
"[[2,6]]"
] | [
"For a number x, the number of \"/4\" operations to change it to 0 is floor(log4(x)) + 1.",
"Always pair the 2 numbers with the maximum \"/4\" operations needed."
] | {
"canonical_parameter_names": [
"queries"
],
"leetcode_dataset_entry_point": "Solution().minOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:20",
"tests_total": 94,
"tests... | typescript | {
"raw_signature": "function minOperations(queries: number[][]): number {",
"container": null,
"callable": "minOperations",
"parameters": [
{
"name": "queries",
"type": "number[][]"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
3,498 | reverse-degree-of-a-string | Easy | Given a string s, calculate its reverse degree.
The reverse degree is calculated as follows:
1. For each character, multiply its position in the reversed alphabet ('a' = 26, 'b' = 25, ..., 'z' = 1) with its position in the string (1-indexed).
2. Sum these products for all characters in the string.
Return the reverse... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"zzzz\") == 10\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 15678\n assert candidate(s = \"world\") == 230\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 3276\n assert ca... | [
"\"abc\"",
"\"zaza\""
] | [
"Simulate the operations as described."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().reverseDegree",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:25",
"tests_total": 55,
"tests_dropp... | typescript | {
"raw_signature": "function reverseDegree(s: string): number {",
"container": null,
"callable": "reverseDegree",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,499 | maximize-active-section-with-trade-i | Medium | You are given a binary string s of length n, where:
- '1' represents an active section.
- '0' represents an inactive section.
You can perform at most one trade to maximize the number of active sections in s. In a trade, you:
- Convert a contiguous block of '1's that is surrounded by '0's to all '0's.
- Afterward, co... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"01010\") == 4\n assert candidate(s = \"1000100\") == 7\n assert candidate(s = \"010101010\") == 6\n assert candidate(s = \"1001001001\") == 8\n assert candidate(s = \"11111\") == 5\n assert candidate(s = \"0011001100... | [
"\"01\"",
"\"0100\"",
"\"1000100\"",
"\"01010\""
] | [
"Split the string into several zero-one segments.",
"For each one-segment, if it has two neighbors (i.e., it is surrounded by two zero-segments), the total sum of their lengths is one of the candidates for delta.",
"Find the maximum delta and add it to the total number of ones in the string."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().maxActiveSectionsAfterTrade",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:28",
"tests_total": 88,
... | typescript | {
"raw_signature": "function maxActiveSectionsAfterTrade(s: string): number {",
"container": null,
"callable": "maxActiveSectionsAfterTrade",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "number",
"signature_source": "leetcode/codeSnippets",
"type_source": "lee... |
3,500 | minimum-cost-to-divide-array-into-subarrays | Hard | You are given two integer arrays, nums and cost, of the same size, and an integer k.
You can divide nums into subarrays. The cost of the i^th subarray consisting of elements nums[l..r] is:
- (nums[0] + nums[1] + ... + nums[r] + k * i) * (cost[l] + cost[l + 1] + ... + cost[r]).
Note that i represents the order of the... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1],cost = [1],k = 1) == 2\n assert candidate(nums = [4, 8, 5, 1, 14, 2, 2, 12, 1],cost = [7, 2, 8, 4, 2, 2, 1, 1, 2],k = 7) == 985\n assert candidate(nums = [1, 2, 3, 4, 5],cost = [5, 4, 3, 2, 1],k = 2) == 130\n assert c... | [
"[3,1,4]\n[4,6,6]\n1",
"[4,8,5,1,14,2,2,12,1]\n[7,2,8,4,2,2,1,1,2]\n7"
] | [
"dp[i] is the minimum cost to split the array suffix starting at i.",
"Observe that no matter how many subarrays we have, if we have the first subarray on the left, the total cost of the previous subarrays increases by k * total_cost_of_the_subarray. This is because when we increase i to (i + 1), the cost increas... | {
"canonical_parameter_names": [
"nums",
"cost",
"k"
],
"leetcode_dataset_entry_point": "Solution().minimumCost",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:31",
"tests_tota... | typescript | {
"raw_signature": "function minimumCost(nums: number[], cost: number[], k: number): number {",
"container": null,
"callable": "minimumCost",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "cost",
"type": "number[]"
},
{
"name": "k",
"ty... |
3,501 | maximize-active-section-with-trade-ii | Hard | You are given a binary string s of length n, where:
- '1' represents an active section.
- '0' represents an inactive section.
You can perform at most one trade to maximize the number of active sections in s. In a trade, you:
- Convert a contiguous block of '1's that is surrounded by '0's to all '0's.
- Afterward, co... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"0100\",queries = [[0, 3], [0, 2], [1, 3], [2, 3]]) == [4, 3, 1, 1]\n assert candidate(s = \"01\",queries = [[0, 1]]) == [1]\n assert candidate(s = \"01010\",queries = [[0, 3], [1, 4], [1, 3]]) == [4, 4, 2]\n assert candida... | [
"\"01\"\n[[0,1]]",
"\"0100\"\n[[0,3],[0,2],[1,3],[2,3]]",
"\"1000100\"\n[[1,5],[0,6],[0,4]]",
"\"01010\"\n[[0,3],[1,4],[1,3]]"
] | [
"Split consecutive zeros and ones into segments and give each segment an ID.",
"The answer should be the maximum of ans[i] = len[i - 1] + len[i + 1], where i is a one-segment.",
"For a zero-segment, define ans[i] = 0.",
"Note that all three segments (i - 1, i, and i + 1) should be fully covered by the substri... | {
"canonical_parameter_names": [
"s",
"queries"
],
"leetcode_dataset_entry_point": "Solution().maxActiveSectionsAfterTrade",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:34",
"tes... | typescript | {
"raw_signature": "function maxActiveSectionsAfterTrade(s: string, queries: number[][]): number[] {",
"container": null,
"callable": "maxActiveSectionsAfterTrade",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "queries",
"type": "number[][]"
}
],
"retu... |
3,502 | minimum-cost-to-reach-every-position | Easy | You are given an integer array cost of size n. You are currently at position n (at the end of the line) in a line of n + 1 people (numbered from 0 to n).
You wish to move forward in the line, but each person in front of you charges a specific amount to swap places. The cost to swap with person i is given by cost[i].
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(cost = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(cost = [10, 20, 30, 40, 50]) == [10, 10, 10, 10, 10]\n assert candidate(cost = [50, 25, 75, 100, 20, 30, 40, 60, 80, 90]) == [50, 25, ... | [
"[5,3,4,1,3,2]",
"[1,2,4,6,7]"
] | [
"Note that once you swap to a position with a lower cost, you can reach any later position for free.",
"Use a min prefix array."
] | {
"canonical_parameter_names": [
"cost"
],
"leetcode_dataset_entry_point": "Solution().minCosts",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:36",
"tests_total": 109,
"tests_droppe... | typescript | {
"raw_signature": "function minCosts(cost: number[]): number[] {",
"container": null,
"callable": "minCosts",
"parameters": [
{
"name": "cost",
"type": "number[]"
}
],
"return_type": "number[]",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,503 | longest-palindrome-after-substring-concatenation-i | Medium | You are given two strings, s and t.
You can create a new string by selecting a substring from s (possibly empty) and a substring from t (possibly empty), then concatenating them in order.
Return the length of the longest palindrome that can be formed this way.
Example 1:
Input: s = "a", t = "a"
Output: 2
Explanatio... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"b\",t = \"aaaa\") == 4\n assert candidate(s = \"hello\",t = \"world\") == 3\n assert candidate(s = \"different\",t = \"entirely\") == 5\n assert candidate(s = \"level\",t = \"deified\") == 7\n assert candidate(s = \"xyz... | [
"\"a\"\n\"a\"",
"\"abc\"\n\"def\"",
"\"b\"\n\"aaaa\"",
"\"abcde\"\n\"ecdba\""
] | [
"Brute force"
] | {
"canonical_parameter_names": [
"s",
"t"
],
"leetcode_dataset_entry_point": "Solution().longestPalindrome",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:39",
"tests_total": 101,
... | typescript | {
"raw_signature": "function longestPalindrome(s: string, t: string): number {",
"container": null,
"callable": "longestPalindrome",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "t",
"type": "string"
}
],
"return_type": "number",
"signature_source": ... |
3,504 | longest-palindrome-after-substring-concatenation-ii | Hard | You are given two strings, s and t.
You can create a new string by selecting a substring from s (possibly empty) and a substring from t (possibly empty), then concatenating them in order.
Return the length of the longest palindrome that can be formed this way.
Example 1:
Input: s = "a", t = "a"
Output: 2
Explanatio... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"b\",t = \"aaaa\") == 4\n assert candidate(s = \"hello\",t = \"world\") == 3\n assert candidate(s = \"aaaa\",t = \"bbbb\") == 4\n assert candidate(s = \"abcde\",t = \"ecdba\") == 5\n assert candidate(s = \"noon\",t = \"m... | [
"\"a\"\n\"a\"",
"\"abc\"\n\"def\"",
"\"b\"\n\"aaaa\"",
"\"abcde\"\n\"ecdba\""
] | [
"Let dp[i][j] be the length of the longest answer if we try starting it with s[i] and ending it with t[j].",
"For s, preprocess the length of the longest palindrome starting at index i as p[i].",
"For t, preprocess the length of the longest palindrome ending at index j as q[j].",
"If s[i] != t[j], then dp[i][... | {
"canonical_parameter_names": [
"s",
"t"
],
"leetcode_dataset_entry_point": "Solution().longestPalindrome",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:41",
"tests_total": 122,
... | typescript | {
"raw_signature": "function longestPalindrome(s: string, t: string): number {",
"container": null,
"callable": "longestPalindrome",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "t",
"type": "string"
}
],
"return_type": "number",
"signature_source": ... |
3,505 | minimum-operations-to-make-elements-within-k-subarrays-equal | Hard | You are given an integer array nums and two integers, x and k. You can perform the following operation any number of times (including zero):
- Increase or decrease any element of nums by 1.
Return the minimum number of operations needed to have at least k non-overlapping subarrays of size exactly x in nums, where all... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000, 1000000],x = 2,k = 2) == 4000000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 10,k = 1) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1... | [
"[5,-2,1,3,7,3,6,4,-1]\n3\n2",
"[9,-2,-2,-2,1,5]\n2\n2"
] | [
"Making every element of an x-sized window equal to its median is optimal.",
"Precalculate this for each window."
] | {
"canonical_parameter_names": [
"nums",
"x",
"k"
],
"leetcode_dataset_entry_point": "Solution().minOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T21:27:44",
"tests_total... | typescript | {
"raw_signature": "function minOperations(nums: number[], x: number, k: number): number {",
"container": null,
"callable": "minOperations",
"parameters": [
{
"name": "nums",
"type": "number[]"
},
{
"name": "x",
"type": "number"
},
{
"name": "k",
"type": "... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.