question_id int64 3.24k 3.51k | task_id stringclasses 201
values | difficulty stringclasses 3
values | problem_description stringclasses 201
values | canonical_tests dict | metadata dict | language stringclasses 9
values | interface dict |
|---|---|---|---|---|---|---|---|
3,243 | shortest-distance-after-road-addition-queries-i | Medium | You are given an integer n and a 2D integer array queries.
There are n cities numbered from 0 to n - 1. Initially, there is a unidirectional road from city i to city i + 1 for all 0 <= i < n - 1.
queries[i] = [ui, vi] represents the addition of a new unidirectional road from city ui to city vi. After each query, you ne... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 7,queries = [[0, 5], [1, 6], [2, 4]]) == [2, 2, 2]\n assert candidate(n = 8,queries = [[1, 5], [2, 6], [3, 7], [0, 4], [0, 6], [0, 7]]) == [4, 4, 4, 4, 2, 1]\n assert candidate(n = 6,queries = [[1, 3], [2, 5], [0, 3]]) == [4, 3... | {
"canonical_parameter_names": [
"n",
"queries"
],
"leetcode_dataset_entry_point": "Solution().shortestDistanceAfterQueries",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> shortestDistanceAfterQueries(int n, vector<vector<int>>& queries) {",
"container": "Solution",
"callable": "shortestDistanceAfterQueries",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "queries",
"type": "vector<vector<int>>&"
}... |
3,244 | shortest-distance-after-road-addition-queries-ii | Hard | You are given an integer n and a 2D integer array queries.
There are n cities numbered from 0 to n - 1. Initially, there is a unidirectional road from city i to city i + 1 for all 0 <= i < n - 1.
queries[i] = [ui, vi] represents the addition of a new unidirectional road from city ui to city vi. After each query, you ne... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 7,queries = [[3, 6], [1, 3], [0, 1], [0, 6]]) == [4, 3, 3, 1]\n assert candidate(n = 8,queries = [[2, 7], [0, 2], [4, 6], [0, 4]]) == [3, 2, 2, 1]\n assert candidate(n = 5,queries = [[2, 4], [0, 2], [0, 4]]) == [3, 2, 1]\n a... | {
"canonical_parameter_names": [
"n",
"queries"
],
"leetcode_dataset_entry_point": "Solution().shortestDistanceAfterQueries",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> shortestDistanceAfterQueries(int n, vector<vector<int>>& queries) {",
"container": "Solution",
"callable": "shortestDistanceAfterQueries",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "queries",
"type": "vector<vector<int>>&"
}... |
3,248 | snake-in-matrix | Easy | There is a snake in an n x n matrix grid and can move in four possible directions. Each cell in the grid is identified by the position: grid[i][j] = (i * n) + j.
The snake starts at cell 0 and follows a sequence of commands.
You are given an integer n representing the size of the grid and an array of strings commands w... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 2,commands = ['RIGHT', 'DOWN']) == 3\n assert candidate(n = 5,commands = ['RIGHT', 'DOWN', 'RIGHT', 'DOWN', 'RIGHT', 'DOWN']) == 18\n assert candidate(n = 10,commands = ['UP', 'LEFT', 'DOWN', 'RIGHT', 'UP', 'LEFT', 'DOWN', 'RIG... | {
"canonical_parameter_names": [
"n",
"commands"
],
"leetcode_dataset_entry_point": "Solution().finalPositionOfSnake",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int finalPositionOfSnake(int n, vector<string>& commands) {",
"container": "Solution",
"callable": "finalPositionOfSnake",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "commands",
"type": "vector<string>&"
}
],
"return_type": "int",
... |
3,249 | count-the-number-of-good-nodes | Medium | There is an undirected tree with n nodes labeled from 0 to n - 1, and rooted at node 0. You are given a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.
A node is good if all the subtrees rooted at its children have the same size.
Ret... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [1, 6], [2, 7], [3, 8]]) == 6\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [1, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], [9, 12], [10, 11]]) == 12\n assert candidat... | {
"canonical_parameter_names": [
"edges"
],
"leetcode_dataset_entry_point": "Solution().countGoodNodes",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int countGoodNodes(vector<vector<int>>& edges) {",
"container": "Solution",
"callable": "countGoodNodes",
"parameters": [
{
"name": "edges",
"type": "vector<vector<int>>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leet... |
3,250 | find-the-count-of-monotonic-pairs-i | Hard | You are given an array of positive integers nums of length n.
We call a pair of non-negative integer arrays (arr1, arr2) monotonic if:
The lengths of both arrays are n.
arr1 is monotonically non-decreasing, in other words, arr1[0] <= arr1[1] <= ... <= arr1[n - 1].
arr2 is monotonically non-increasing, in other words, ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [50, 1, 50, 1, 50]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3]) == 84\n assert candidate(nums = [10, 20, 30, 40, 50]) == 3003\n assert candidate(nums = [5, 5, 5, 5]) == 126\n assert candidate(nums = [1, 2, 3, 4,... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countOfPairs",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int countOfPairs(vector<int>& nums) {",
"container": "Solution",
"callable": "countOfPairs",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,251 | find-the-count-of-monotonic-pairs-ii | Hard | You are given an array of positive integers nums of length n.
We call a pair of non-negative integer arrays (arr1, arr2) monotonic if:
The lengths of both arrays are n.
arr1 is monotonically non-decreasing, in other words, arr1[0] <= arr1[1] <= ... <= arr1[n - 1].
arr2 is monotonically non-increasing, in other words, ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [2, 3, 2]) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 659632782\n assert candidate(nums = [1, 1, 1, 1, ... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countOfPairs",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int countOfPairs(vector<int>& nums) {",
"container": "Solution",
"callable": "countOfPairs",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,254 | find-the-power-of-k-size-subarrays-i | Medium | You are given an array of integers nums of length n and a positive integer k.
The power of an array is defined as:
Its maximum element if all of its elements are consecutive and sorted in ascending order.
-1 otherwise.
You need to find the power of all subarrays of nums of size k.
Return an integer array results of s... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],k = 5) == [5]\n assert candidate(nums = [2, 2, 2, 2, 2],k = 4) == [-1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11],k = 5) == [-1, -1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5],k = 4) == [-1, -1, ... | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().resultsArray",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> resultsArray(vector<int>& nums, int k) {",
"container": "Solution",
"callable": "resultsArray",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "vector<int>",
"signature_sou... |
3,255 | find-the-power-of-k-size-subarrays-ii | Medium | You are given an array of integers nums of length n and a positive integer k.
The power of an array is defined as:
Its maximum element if all of its elements are consecutive and sorted in ascending order.
-1 otherwise.
You need to find the power of all subarrays of nums of size k.
Return an integer array results of s... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [100, 101, 102, 103, 104, 105],k = 2) == [101, 102, 103, 104, 105]\n assert candidate(nums = [2, 2, 2, 2, 2],k = 4) == [-1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == [1, 2, 3, 4, 5, 6, 7, 8, 9, ... | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().resultsArray",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> resultsArray(vector<int>& nums, int k) {",
"container": "Solution",
"callable": "resultsArray",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "vector<int>",
"signature_sou... |
3,256 | maximum-value-sum-by-placing-three-rooks-i | Hard | You are given a m x n 2D array board representing a chessboard, where board[i][j] represents the value of the cell (i, j).
Rooks in the same row or column attack each other. You need to place three rooks on the chessboard such that the rooks do not attack each other.
Return the maximum sum of the cell values on which t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(board = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]) == 150\n assert candidate(board = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == -15\n assert candidate(board = [[-3, 1, 1, 1], [-3, 1, -3, 1], [-3, 2, 1, 1]]) == 4\n assert ca... | {
"canonical_parameter_names": [
"board"
],
"leetcode_dataset_entry_point": "Solution().maximumValueSum",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long maximumValueSum(vector<vector<int>>& board) {",
"container": "Solution",
"callable": "maximumValueSum",
"parameters": [
{
"name": "board",
"type": "vector<vector<int>>&"
}
],
"return_type": "long long",
"signature_source": "leetcode/codeSnippets",
"type_... |
3,257 | maximum-value-sum-by-placing-three-rooks-ii | Hard | You are given a m x n 2D array board representing a chessboard, where board[i][j] represents the value of the cell (i, j).
Rooks in the same row or column attack each other. You need to place three rooks on the chessboard such that the rooks do not attack each other.
Return the maximum sum of the cell values on which t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(board = [[5, -2, 3, 7], [1, 8, -1, 2], [-4, 4, -3, 6], [3, 7, 5, -9]]) == 20\n assert candidate(board = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 3\n assert candidate(board = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [1... | {
"canonical_parameter_names": [
"board"
],
"leetcode_dataset_entry_point": "Solution().maximumValueSum",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long maximumValueSum(vector<vector<int>>& board) {",
"container": "Solution",
"callable": "maximumValueSum",
"parameters": [
{
"name": "board",
"type": "vector<vector<int>>&"
}
],
"return_type": "long long",
"signature_source": "leetcode/codeSnippets",
"type_... |
3,258 | count-substrings-that-satisfy-k-constraint-i | Easy | You are given a binary string s and an integer k.
A binary string satisfies the k-constraint if either of the following conditions holds:
The number of 0's in the string is at most k.
The number of 1's in the string is at most k.
Return an integer denoting the number of substrings of s that satisfy the k-constraint.
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"0101010101\",k = 5) == 55\n assert candidate(s = \"11111\",k = 1) == 15\n assert candidate(s = \"00000\",k = 2) == 15\n assert candidate(s = \"101010101010\",k = 4) == 72\n assert candidate(s = \"100100100\",k = 3) == 4... | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().countKConstraintSubstrings",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int countKConstraintSubstrings(string s, int k) {",
"container": "Solution",
"callable": "countKConstraintSubstrings",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_source": ... |
3,259 | maximum-energy-boost-from-two-drinks | Medium | You are given two integer arrays energyDrinkA and energyDrinkB of the same length n by a futuristic sports scientist. These arrays represent the energy boosts per hour provided by two different energy drinks, A and B, respectively.
You want to maximize your total energy boost by drinking one energy drink per hour. Howe... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(energyDrinkA = [1, 1, 1, 1, 1, 1],energyDrinkB = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(energyDrinkA = [1, 100000, 1],energyDrinkB = [100000, 1, 100000]) == 200001\n assert candidate(energyDrinkA = [4, 1, 1],energyDrinkB = [1,... | {
"canonical_parameter_names": [
"energyDrinkA",
"energyDrinkB"
],
"leetcode_dataset_entry_point": "Solution().maxEnergyBoost",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long maxEnergyBoost(vector<int>& energyDrinkA, vector<int>& energyDrinkB) {",
"container": "Solution",
"callable": "maxEnergyBoost",
"parameters": [
{
"name": "energyDrinkA",
"type": "vector<int>&"
},
{
"name": "energyDrinkB",
"type": "vector<int>&"
... |
3,260 | find-the-largest-palindrome-divisible-by-k | Hard | You are given two positive integers n and k.
An integer x is called k-palindromic if:
x is a palindrome.
x is divisible by k.
Return the largest integer having n digits (as a string) that is k-palindromic.
Note that the integer must not have leading zeros.
Example 1:
Input: n = 3, k = 5
Output: "595"
Explanation:
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 1,k = 4) == \"8\"\n assert candidate(n = 6,k = 9) == \"999999\"\n assert candidate(n = 6,k = 7) == \"999999\"\n assert candidate(n = 3,k = 5) == \"595\"\n assert candidate(n = 5,k = 6) == \"89898\"\n assert candidate(n... | {
"canonical_parameter_names": [
"n",
"k"
],
"leetcode_dataset_entry_point": "Solution().largestPalindrome",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "string largestPalindrome(int n, int k) {",
"container": "Solution",
"callable": "largestPalindrome",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnip... |
3,261 | count-substrings-that-satisfy-k-constraint-ii | Hard | You are given a binary string s and an integer k.
You are also given a 2D integer array queries, where queries[i] = [li, ri].
A binary string satisfies the k-constraint if either of the following conditions holds:
The number of 0's in the string is at most k.
The number of 1's in the string is at most k.
Return an in... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"010101\",k = 1,queries = [[0, 5], [1, 4], [2, 3]]) == [15, 9, 3]\n assert candidate(s = \"111111\",k = 3,queries = [[0, 5], [1, 4], [2, 3]]) == [21, 10, 3]\n assert candidate(s = \"000000\",k = 3,queries = [[0, 5], [1, 4], [2... | {
"canonical_parameter_names": [
"s",
"k",
"queries"
],
"leetcode_dataset_entry_point": "Solution().countKConstraintSubstrings",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<long long> countKConstraintSubstrings(string s, int k, vector<vector<int>>& queries) {",
"container": "Solution",
"callable": "countKConstraintSubstrings",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "int"
},
{
... |
3,264 | final-array-state-after-k-multiplication-operations-i | Easy | You are given an integer array nums, an integer k, and an integer multiplier.
You need to perform k operations on nums. In each operation:
Find the minimum value x in nums. If there are multiple occurrences of the minimum value, select the one that appears first.
Replace the selected minimum value x with x * multiplie... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [3],k = 1,multiplier = 5) == [15]\n assert candidate(nums = [5, 5, 5, 5],k = 4,multiplier = 2) == [10, 10, 10, 10]\n assert candidate(nums = [10, 9, 8, 7],k = 4,multiplier = 1) == [10, 9, 8, 7]\n assert candidate(nums = [... | {
"canonical_parameter_names": [
"nums",
"k",
"multiplier"
],
"leetcode_dataset_entry_point": "Solution().getFinalState",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> getFinalState(vector<int>& nums, int k, int multiplier) {",
"container": "Solution",
"callable": "getFinalState",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
},
{
"name": "multiplier",
... |
3,265 | count-almost-equal-pairs-i | Medium | You are given an array nums consisting of positive integers.
We call two integers x and y in this problem almost equal if both integers can become equal after performing the following operation at most once:
Choose either x or y and swap any two digits within the chosen number.
Return the number of indices i and j in... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == 0\n assert candidate(nums = [101, 110, 111, 1001, 1100]) == 5\n assert candidate(nums = [12, 21, 13, 31, 14]) == 2\n assert candidate(nums = [12, 21, 13, 31, 23, 32, 45, 5... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countPairs",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int countPairs(vector<int>& nums) {",
"container": "Solution",
"callable": "countPairs",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,266 | final-array-state-after-k-multiplication-operations-ii | Hard | You are given an integer array nums, an integer k, and an integer multiplier.
You need to perform k operations on nums. In each operation:
Find the minimum value x in nums. If there are multiple occurrences of the minimum value, select the one that appears first.
Replace the selected minimum value x with x * multiplie... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 25,multiplier = 1) == [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]\n assert candidate(nums = [1000000000],k = 1000000000,multiplier = 1) == [1000000000]\n"
} | {
"canonical_parameter_names": [
"nums",
"k",
"multiplier"
],
"leetcode_dataset_entry_point": "Solution().getFinalState",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> getFinalState(vector<int>& nums, int k, int multiplier) {",
"container": "Solution",
"callable": "getFinalState",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
},
{
"name": "multiplier",
... |
3,267 | count-almost-equal-pairs-ii | Hard | Attention: In this version, the number of operations that can be performed, has been increased to twice.
You are given an array nums consisting of positive integers.
We call two integers x and y almost equal if both integers can become equal after performing the following operation at most twice:
Choose either x or y ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [123, 321, 213, 132]) == 6\n assert candidate(nums = [1111, 2222, 3333, 4444]) == 0\n assert candidate(nums = [12, 21, 13, 31, 23, 32]) == 3\n assert candidate(nums = [111, 222, 333, 444, 555]) == 0\n assert candidate(... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countPairs",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int countPairs(vector<int>& nums) {",
"container": "Solution",
"callable": "countPairs",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,270 | find-the-key-of-the-numbers | Easy | You are given three positive integers num1, num2, and num3.
The key of num1, num2, and num3 is defined as a four-digit number such that:
Initially, if any number has less than four digits, it is padded with leading zeros.
The ith digit (1 <= i <= 4) of the key is generated by taking the smallest digit among the ith di... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num1 = 9999,num2 = 9999,num3 = 9999) == 9999\n assert candidate(num1 = 1000,num2 = 1000,num3 = 1000) == 1000\n assert candidate(num1 = 12,num2 = 345,num3 = 6789) == 12\n assert candidate(num1 = 5555,num2 = 5555,num3 = 6666) == 5... | {
"canonical_parameter_names": [
"num1",
"num2",
"num3"
],
"leetcode_dataset_entry_point": "Solution().generateKey",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int generateKey(int num1, int num2, int num3) {",
"container": "Solution",
"callable": "generateKey",
"parameters": [
{
"name": "num1",
"type": "int"
},
{
"name": "num2",
"type": "int"
},
{
"name": "num3",
"type": "int"
}
],
"re... |
3,271 | hash-divided-string | Medium | You are given a string s of length n and an integer k, where n is a multiple of k. Your task is to hash the string s into a new string called result, which has a length of n / k.
First, divide s into n / k substrings, each with a length of k. Then, initialize result as an empty string.
For each substring in order from ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"aaaa\",k = 2) == \"aa\"\n assert candidate(s = \"mnopqr\",k = 3) == \"nw\"\n assert candidate(s = \"hellohellohellohello\",k = 5) == \"vvvv\"\n assert candidate(s = \"ababababab\",k = 2) == \"bbbbb\"\n assert candidate(... | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().stringHash",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "string stringHash(string s, int k) {",
"container": "Solution",
"callable": "stringHash",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
... |
3,272 | find-the-count-of-good-integers | Hard | You are given two positive integers n and k.
An integer x is called k-palindromic if:
x is a palindrome.
x is divisible by k.
An integer is called good if its digits can be rearranged to form a k-palindromic integer. For example, for k = 2, 2020 can be rearranged to form the k-palindromic integer 2002, whereas 1010 c... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 6,k = 8) == 5221\n assert candidate(n = 10,k = 9) == 4610368\n assert candidate(n = 1,k = 4) == 2\n assert candidate(n = 6,k = 9) == 1248\n assert candidate(n = 9,k = 1) == 41457015\n assert candidate(n = 8,k = 2) == 5... | {
"canonical_parameter_names": [
"n",
"k"
],
"leetcode_dataset_entry_point": "Solution().countGoodIntegers",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long countGoodIntegers(int n, int k) {",
"container": "Solution",
"callable": "countGoodIntegers",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "long long",
"signature_source": "leetcode/co... |
3,273 | minimum-amount-of-damage-dealt-to-bob | Hard | You are given an integer power and two integer arrays damage and health, both having length n.
Bob has n enemies, where enemy i will deal Bob damage[i] points of damage per second while they are alive (i.e. health[i] > 0).
Every second, after the enemies deal damage to Bob, he chooses one of the enemies that is still a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(power = 2,damage = [1, 1, 1, 1, 1],health = [1, 2, 3, 4, 5]) == 22\n assert candidate(power = 100,damage = [10, 20, 30],health = [100, 100, 100]) == 100\n assert candidate(power = 4,damage = [1, 2, 3, 4],health = [4, 5, 6, 8]) == 3... | {
"canonical_parameter_names": [
"power",
"damage",
"health"
],
"leetcode_dataset_entry_point": "Solution().minDamage",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long minDamage(int power, vector<int>& damage, vector<int>& health) {",
"container": "Solution",
"callable": "minDamage",
"parameters": [
{
"name": "power",
"type": "int"
},
{
"name": "damage",
"type": "vector<int>&"
},
{
"name": "health... |
3,274 | check-if-two-chessboard-squares-have-the-same-color | Easy | You are given two strings, coordinate1 and coordinate2, representing the coordinates of a square on an 8 x 8 chessboard.
Below is the chessboard for reference.
Return true if these two squares have the same color and false otherwise.
The coordinate will always represent a valid chessboard square. The coordinate will a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(coordinate1 = \"g7\",coordinate2 = \"f8\") == True\n assert candidate(coordinate1 = \"a1\",coordinate2 = \"c3\") == True\n assert candidate(coordinate1 = \"e5\",coordinate2 = \"g7\") == True\n assert candidate(coordinate1 = \"b2... | {
"canonical_parameter_names": [
"coordinate1",
"coordinate2"
],
"leetcode_dataset_entry_point": "Solution().checkTwoChessboards",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "bool checkTwoChessboards(string coordinate1, string coordinate2) {",
"container": "Solution",
"callable": "checkTwoChessboards",
"parameters": [
{
"name": "coordinate1",
"type": "string"
},
{
"name": "coordinate2",
"type": "string"
}
],
"return_typ... |
3,275 | k-th-nearest-obstacle-queries | Medium | There is an infinite 2D plane.
You are given a positive integer k. You are also given a 2D array queries, which contains the following queries:
queries[i] = [x, y]: Build an obstacle at coordinate (x, y) in the plane. It is guaranteed that there is no obstacle at this coordinate when this query is made.
After each qu... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(queries = [[5, 5], [4, 4], [3, 3]],k = 1) == [10, 8, 6]\n assert candidate(queries = [[-1000000000, 1000000000], [1000000000, -1000000000]],k = 1) == [2000000000, 2000000000]\n assert candidate(queries = [[-1, 1], [0, 0], [1, -1]],... | {
"canonical_parameter_names": [
"queries",
"k"
],
"leetcode_dataset_entry_point": "Solution().resultsArray",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> resultsArray(vector<vector<int>>& queries, int k) {",
"container": "Solution",
"callable": "resultsArray",
"parameters": [
{
"name": "queries",
"type": "vector<vector<int>>&"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "vector<i... |
3,276 | select-cells-in-grid-with-maximum-score | Hard | You are given a 2D matrix grid consisting of positive integers.
You have to select one or more cells from the matrix such that the following conditions are satisfied:
No two selected cells are in the same row of the matrix.
The values in the set of selected cells are unique.
Your score will be the sum of the values o... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 5\n assert candidate(grid = [[8, 7, 6], [8, 3, 2]]) == 15\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1]]) == 12\n assert candidate(grid = [[5, 9, 1], [9... | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().maxScore",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int maxScore(vector<vector<int>>& grid) {",
"container": "Solution",
"callable": "maxScore",
"parameters": [
{
"name": "grid",
"type": "vector<vector<int>>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnipp... |
3,277 | maximum-xor-score-subarray-queries | Hard | You are given an array nums of n integers, and a 2D integer array queries of size q, where queries[i] = [li, ri].
For each query, you must find the maximum XOR score of any subarray of nums[li..ri].
The XOR score of an array a is found by repeatedly applying the following operations on a so that only one element remain... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [0, 7, 3, 2, 8, 5, 1],queries = [[0, 3], [1, 5], [2, 4], [2, 6], [5, 6]]) == [7, 14, 11, 14, 5]\n assert candidate(nums = [2, 8, 4, 32, 16, 1],queries = [[0, 2], [1, 4], [0, 5]]) == [12, 60, 60]\n assert candidate(nums = [10... | {
"canonical_parameter_names": [
"nums",
"queries"
],
"leetcode_dataset_entry_point": "Solution().maximumSubarrayXor",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> maximumSubarrayXor(vector<int>& nums, vector<vector<int>>& queries) {",
"container": "Solution",
"callable": "maximumSubarrayXor",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "queries",
"type": "vector<vector<int>>&"
... |
3,280 | convert-date-to-binary | Easy | You are given a string date representing a Gregorian calendar date in the yyyy-mm-dd format.
date can be written in its binary representation obtained by converting year, month, and day to their binary representations without any leading zeroes and writing them down in year-month-day format.
Return the binary represent... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(date = \"1950-06-30\") == \"11110011110-110-11110\"\n assert candidate(date = \"1912-04-20\") == \"11101111000-100-10100\"\n assert candidate(date = \"2080-02-29\") == \"100000100000-10-11101\"\n assert candidate(date = \"2023-1... | {
"canonical_parameter_names": [
"date"
],
"leetcode_dataset_entry_point": "Solution().convertDateToBinary",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "string convertDateToBinary(string date) {",
"container": "Solution",
"callable": "convertDateToBinary",
"parameters": [
{
"name": "date",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnipp... |
3,281 | maximize-score-of-numbers-in-ranges | Medium | You are given an array of integers start and an integer d, representing n intervals [start[i], start[i] + d].
You are asked to choose n integers where the ith integer must belong to the ith interval. The score of the chosen integers is defined as the minimum absolute difference between any two integers that have been c... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(start = [5, 10, 15, 20, 25],d = 4) == 6\n assert candidate(start = [1, 10, 20, 30],d = 9) == 12\n assert candidate(start = [10, 20, 30, 40, 50],d = 15) == 13\n assert candidate(start = [100, 200, 300, 400, 500],d = 50) == 112\n ... | {
"canonical_parameter_names": [
"start",
"d"
],
"leetcode_dataset_entry_point": "Solution().maxPossibleScore",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int maxPossibleScore(vector<int>& start, int d) {",
"container": "Solution",
"callable": "maxPossibleScore",
"parameters": [
{
"name": "start",
"type": "vector<int>&"
},
{
"name": "d",
"type": "int"
}
],
"return_type": "int",
"signature_source": ... |
3,282 | reach-end-of-array-with-max-score | Medium | You are given an integer array nums of length n.
Your goal is to start at index 0 and reach index n - 1. You can only jump to indices greater than your current index.
The score for a jump from index i to index j is calculated as (j - i) * nums[i].
Return the maximum possible total score by the time you reach the last i... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [2, 3, 5, 6, 7, 8]) == 23\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [2, 4, 6, 8, 10]) == 20\n assert candidate(nums = [4, 3, 1, 3, 2]) == 16\n assert candidate(nums = [1... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().findMaximumScore",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long findMaximumScore(vector<int>& nums) {",
"container": "Solution",
"callable": "findMaximumScore",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "long long",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetco... |
3,283 | maximum-number-of-moves-to-kill-all-pawns | Hard | There is a 50 x 50 chessboard with one knight and some pawns on it. You are given two integers kx and ky where (kx, ky) denotes the position of the knight, and a 2D array positions where positions[i] = [xi, yi] denotes the position of the pawns on the chessboard.
Alice and Bob play a turn-based game, where Alice goes f... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(kx = 49,ky = 49,positions = [[48, 47], [47, 45]]) == 3\n assert candidate(kx = 0,ky = 2,positions = [[1, 1], [2, 2], [3, 3]]) == 8\n assert candidate(kx = 10,ky = 10,positions = [[5, 5], [15, 15], [20, 20]]) == 20\n assert candi... | {
"canonical_parameter_names": [
"kx",
"ky",
"positions"
],
"leetcode_dataset_entry_point": "Solution().maxMoves",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int maxMoves(int kx, int ky, vector<vector<int>>& positions) {",
"container": "Solution",
"callable": "maxMoves",
"parameters": [
{
"name": "kx",
"type": "int"
},
{
"name": "ky",
"type": "int"
},
{
"name": "positions",
"type": "vector<v... |
3,285 | find-indices-of-stable-mountains | Easy | There are n mountains in a row, and each mountain has a height. You are given an integer array height where height[i] represents the height of mountain i, and an integer threshold.
A mountain is called stable if the mountain just before it (if it exists) has a height strictly greater than threshold. Note that mountain ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(height = [50, 50, 50, 50, 50],threshold = 49) == [1, 2, 3, 4]\n assert candidate(height = [2, 3, 2, 3, 2],threshold = 2) == [2, 4]\n assert candidate(height = [5, 4, 3, 2, 1],threshold = 3) == [1, 2]\n assert candidate(height = ... | {
"canonical_parameter_names": [
"height",
"threshold"
],
"leetcode_dataset_entry_point": "Solution().stableMountains",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> stableMountains(vector<int>& height, int threshold) {",
"container": "Solution",
"callable": "stableMountains",
"parameters": [
{
"name": "height",
"type": "vector<int>&"
},
{
"name": "threshold",
"type": "int"
}
],
"return_type": "vect... |
3,286 | find-a-safe-walk-through-a-grid | Medium | You are given an m x n binary matrix grid and an integer health.
You start on the upper-left corner (0, 0) and would like to get to the lower-right corner (m - 1, n - 1).
You can move up, down, left, or right from one cell to another adjacent cell as long as your health remains positive.
Cells (i, j) with grid[i][j] = ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[0, 1, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 1, 0]],health = 1) == True\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],health = 1) == True\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]],health = 5) ... | {
"canonical_parameter_names": [
"grid",
"health"
],
"leetcode_dataset_entry_point": "Solution().findSafeWalk",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "bool findSafeWalk(vector<vector<int>>& grid, int health) {",
"container": "Solution",
"callable": "findSafeWalk",
"parameters": [
{
"name": "grid",
"type": "vector<vector<int>>&"
},
{
"name": "health",
"type": "int"
}
],
"return_type": "bool",
"s... |
3,287 | find-the-maximum-sequence-value-of-array | Hard | You are given an integer array nums and a positive integer k.
The value of a sequence seq of size 2 * x is defined as:
(seq[0] OR seq[1] OR ... OR seq[x - 1]) XOR (seq[x] OR seq[x + 1] OR ... OR seq[2 * x - 1]).
Return the maximum value of any subsequence of nums having size 2 * k.
Example 1:
Input: nums = [2,6,7]... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 7, 9, 11],k = 3) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 0\n assert candidate(nums = [31, 15, 7, 3, 1],k = 2) == 28\n assert candidate(nums = [26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16... | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxValue",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int maxValue(vector<int>& nums, int k) {",
"container": "Solution",
"callable": "maxValue",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnip... |
3,288 | length-of-the-longest-increasing-path | Hard | You are given a 2D array of integers coordinates of length n and an integer k, where 0 <= k < n.
coordinates[i] = [xi, yi] indicates the point (xi, yi) in a 2D plane.
An increasing path of length m is defined as a list of points (x1, y1), (x2, y2), (x3, y3), ..., (xm, ym) such that:
xi < xi + 1 and yi < yi + 1 for all... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],k = 4) == 7\n assert candidate(coordinates = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5]],k = 4) == 1\n assert candidate(coordinates = [[10, 9], [9, 8], [8, 7], [7... | {
"canonical_parameter_names": [
"coordinates",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxPathLength",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int maxPathLength(vector<vector<int>>& coordinates, int k) {",
"container": "Solution",
"callable": "maxPathLength",
"parameters": [
{
"name": "coordinates",
"type": "vector<vector<int>>&"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
... |
3,289 | the-two-sneaky-numbers-of-digitville | Easy | In the town of Digitville, there was a list of numbers called nums containing integers from 0 to n - 1. Each number was supposed to appear exactly once in the list, however, two mischievous numbers sneaked in an additional time, making the list longer than usual.
As the town detective, your task is to find these two sn... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 5, 3, 2, 1, 4, 0]) == [5]\n assert candidate(nums = [7, 1, 5, 4, 3, 4, 6, 0, 9, 5, 8, 2]) == [5, 4]\n assert candidate(nums = [0, 1, 1, 0]) == [0, 1]\n assert candidate(nums = [2, 2, 0, 1]) == [2]\n assert candidat... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().getSneakyNumbers",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> getSneakyNumbers(vector<int>& nums) {",
"container": "Solution",
"callable": "getSneakyNumbers",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "vector<int>",
"signature_source": "leetcode/codeSnippets",
"type_source": "le... |
3,290 | maximum-multiplication-score | Medium | You are given an integer array a of size 4 and another integer array b of size at least 4.
You need to choose 4 indices i0, i1, i2, and i3 from the array b such that i0 < i1 < i2 < i3. Your score will be equal to the value a[0] * b[i0] + a[1] * b[i1] + a[2] * b[i2] + a[3] * b[i3].
Return the maximum score you can achie... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(a = [0, 0, 0, 0],b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(a = [1, 2, 3, 4],b = [10, 20, 30, 40, 50, 60, 70, 80]) == 700\n assert candidate(a = [10, 20, 30, 40],b = [1, 2, 3, 4]) == 300\n assert candidate(a = ... | {
"canonical_parameter_names": [
"a",
"b"
],
"leetcode_dataset_entry_point": "Solution().maxScore",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long maxScore(vector<int>& a, vector<int>& b) {",
"container": "Solution",
"callable": "maxScore",
"parameters": [
{
"name": "a",
"type": "vector<int>&"
},
{
"name": "b",
"type": "vector<int>&"
}
],
"return_type": "long long",
"signature_sou... |
3,291 | minimum-number-of-valid-strings-to-form-target-i | Medium | You are given an array of strings words and a string target.
A string x is called valid if x is a prefix of any string in words.
Return the minimum number of valid strings that can be concatenated to form target. If it is not possible to form target, return -1.
Example 1:
Input: words = ["abc","aaaaa","bcdef"], targ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(words = ['abc'],target = \"abcabc\") == 2\n assert candidate(words = ['ab', 'ba'],target = \"abab\") == 2\n assert candidate(words = ['a', 'b', 'c', 'd'],target = \"abcdabcdabcd\") == 12\n assert candidate(words = ['abcde', 'fgh... | {
"canonical_parameter_names": [
"words",
"target"
],
"leetcode_dataset_entry_point": "Solution().minValidStrings",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int minValidStrings(vector<string>& words, string target) {",
"container": "Solution",
"callable": "minValidStrings",
"parameters": [
{
"name": "words",
"type": "vector<string>&"
},
{
"name": "target",
"type": "string"
}
],
"return_type": "int",
... |
3,292 | minimum-number-of-valid-strings-to-form-target-ii | Hard | You are given an array of strings words and a string target.
A string x is called valid if x is a prefix of any string in words.
Return the minimum number of valid strings that can be concatenated to form target. If it is not possible to form target, return -1.
Example 1:
Input: words = ["abc","aaaaa","bcdef"], targ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(words = ['abc'],target = \"abcabc\") == 2\n assert candidate(words = ['a'],target = \"a\") == 1\n assert candidate(words = ['a', 'aa', 'aaa'],target = \"aaaaaaaa\") == 3\n assert candidate(words = ['xyz'],target = \"xyz\") == 1\... | {
"canonical_parameter_names": [
"words",
"target"
],
"leetcode_dataset_entry_point": "Solution().minValidStrings",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int minValidStrings(vector<string>& words, string target) {",
"container": "Solution",
"callable": "minValidStrings",
"parameters": [
{
"name": "words",
"type": "vector<string>&"
},
{
"name": "target",
"type": "string"
}
],
"return_type": "int",
... |
3,295 | report-spam-message | Medium | You are given an array of strings message and an array of strings bannedWords.
An array of words is considered spam if there are at least two words in it that exactly match any word in bannedWords.
Return true if the array message is spam, and false otherwise.
Example 1:
Input: message = ["hello","world","leetcode"]... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(message = ['spam', 'egg', 'ham'],bannedWords = ['spam', 'bacon', 'egg']) == True\n assert candidate(message = ['spam', 'eggs', 'spam'],bannedWords = ['spam']) == True\n assert candidate(message = ['spam', 'spam', 'spam'],bannedWord... | {
"canonical_parameter_names": [
"message",
"bannedWords"
],
"leetcode_dataset_entry_point": "Solution().reportSpam",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "bool reportSpam(vector<string>& message, vector<string>& bannedWords) {",
"container": "Solution",
"callable": "reportSpam",
"parameters": [
{
"name": "message",
"type": "vector<string>&"
},
{
"name": "bannedWords",
"type": "vector<string>&"
}
],
"... |
3,296 | minimum-number-of-seconds-to-make-mountain-height-zero | Medium | You are given an integer mountainHeight denoting the height of a mountain.
You are also given an integer array workerTimes representing the work time of workers in seconds.
The workers work simultaneously to reduce the height of the mountain. For worker i:
To decrease the mountain's height by x, it takes workerTimes[i... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(mountainHeight = 15,workerTimes = [5, 5, 5]) == 75\n assert candidate(mountainHeight = 15,workerTimes = [1, 2, 3]) == 30\n assert candidate(mountainHeight = 15,workerTimes = [1, 2, 3, 4, 5]) == 18\n assert candidate(mountainHeig... | {
"canonical_parameter_names": [
"mountainHeight",
"workerTimes"
],
"leetcode_dataset_entry_point": "Solution().minNumberOfSeconds",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long minNumberOfSeconds(int mountainHeight, vector<int>& workerTimes) {",
"container": "Solution",
"callable": "minNumberOfSeconds",
"parameters": [
{
"name": "mountainHeight",
"type": "int"
},
{
"name": "workerTimes",
"type": "vector<int>&"
}
]... |
3,297 | count-substrings-that-can-be-rearranged-to-contain-a-string-i | Medium | You are given two strings word1 and word2.
A string x is called valid if x can be rearranged to have word2 as a prefix.
Return the total number of valid substrings of word1.
Example 1:
Input: word1 = "bcca", word2 = "abc"
Output: 1
Explanation:
The only valid substring is "bcca" which can be rearranged to "abcc" hav... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word1 = \"banana\",word2 = \"ban\") == 4\n assert candidate(word1 = \"abc\",word2 = \"abcd\") == 0\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(word1 =... | {
"canonical_parameter_names": [
"word1",
"word2"
],
"leetcode_dataset_entry_point": "Solution().validSubstringCount",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long validSubstringCount(string word1, string word2) {",
"container": "Solution",
"callable": "validSubstringCount",
"parameters": [
{
"name": "word1",
"type": "string"
},
{
"name": "word2",
"type": "string"
}
],
"return_type": "long long",
... |
3,298 | count-substrings-that-can-be-rearranged-to-contain-a-string-ii | Hard | You are given two strings word1 and word2.
A string x is called valid if x can be rearranged to have word2 as a prefix.
Return the total number of valid substrings of word1.
Note that the memory limits in this problem are smaller than usual, so you must implement a solution with a linear runtime complexity.
Example 1... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word1 = \"bcca\",word2 = \"abc\") == 1\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(word1 = \"aabbcc\",word2 = \"abc\") == 4\n assert candidate(word1 =... | {
"canonical_parameter_names": [
"word1",
"word2"
],
"leetcode_dataset_entry_point": "Solution().validSubstringCount",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long validSubstringCount(string word1, string word2) {",
"container": "Solution",
"callable": "validSubstringCount",
"parameters": [
{
"name": "word1",
"type": "string"
},
{
"name": "word2",
"type": "string"
}
],
"return_type": "long long",
... |
3,300 | minimum-element-after-replacement-with-digit-sum | Easy | You are given an integer array nums.
You replace each element in nums with the sum of its digits.
Return the minimum element in nums after all replacements.
Example 1:
Input: nums = [10,12,13,14]
Output: 1
Explanation:
nums becomes [1, 3, 4, 5] after all replacements, with minimum element 1.
Example 2:
Input: nums... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [9999, 1001, 1111]) == 2\n assert candidate(nums = [111, 222, 333]) == 3\n assert candidate(nums = [1234, 4321, 2134, 3412]) == 10\n assert candidate(nums = [10, 12, 13, 14]) == 1\n assert candidate(nums = [100, 200, 3... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().minElement",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int minElement(vector<int>& nums) {",
"container": "Solution",
"callable": "minElement",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,301 | maximize-the-total-height-of-unique-towers | Medium | You are given an array maximumHeight, where maximumHeight[i] denotes the maximum height the ith tower can be assigned.
Your task is to assign a height to each tower so that:
The height of the ith tower is a positive integer and does not exceed maximumHeight[i].
No two towers have the same height.
Return the maximum p... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(maximumHeight = [2, 3, 4, 3]) == 10\n assert candidate(maximumHeight = [5, 5, 5, 5, 5]) == 15\n assert candidate(maximumHeight = [1, 2, 3, 4, 5]) == 15\n assert candidate(maximumHeight = [1000000000, 999999999, 999999998, 999999... | {
"canonical_parameter_names": [
"maximumHeight"
],
"leetcode_dataset_entry_point": "Solution().maximumTotalSum",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long maximumTotalSum(vector<int>& maximumHeight) {",
"container": "Solution",
"callable": "maximumTotalSum",
"parameters": [
{
"name": "maximumHeight",
"type": "vector<int>&"
}
],
"return_type": "long long",
"signature_source": "leetcode/codeSnippets",
"type_... |
3,302 | find-the-lexicographically-smallest-valid-sequence | Medium | You are given two strings word1 and word2.
A string x is called almost equal to y if you can change at most one character in x to make it identical to y.
A sequence of indices seq is called valid if:
The indices are sorted in ascending order.
Concatenating the characters at these indices in word1 in the same order res... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word1 = \"hello\",word2 = \"heo\") == [0, 1, 2]\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23... | {
"canonical_parameter_names": [
"word1",
"word2"
],
"leetcode_dataset_entry_point": "Solution().validSequence",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> validSequence(string word1, string word2) {",
"container": "Solution",
"callable": "validSequence",
"parameters": [
{
"name": "word1",
"type": "string"
},
{
"name": "word2",
"type": "string"
}
],
"return_type": "vector<int>",
"signatu... |
3,303 | find-the-occurrence-of-first-almost-equal-substring | Hard | You are given two strings s and pattern.
A string x is called almost equal to y if you can change at most one character in x to make it identical to y.
Return the smallest starting index of a substring in s that is almost equal to pattern. If no such index exists, return -1.
A substring is a contiguous non-empty sequen... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"mississippi\",pattern = \"missiippi\") == -1\n assert candidate(s = \"abcd\",pattern = \"dba\") == -1\n assert candidate(s = \"abcdefghij\",pattern = \"abcdefghii\") == 0\n assert candidate(s = \"abcdefghij\",pattern = \"a... | {
"canonical_parameter_names": [
"s",
"pattern"
],
"leetcode_dataset_entry_point": "Solution().minStartingIndex",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int minStartingIndex(string s, string pattern) {",
"container": "Solution",
"callable": "minStartingIndex",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "pattern",
"type": "string"
}
],
"return_type": "int",
"signature_source": "l... |
3,304 | find-the-k-th-character-in-string-game-i | Easy | Alice and Bob are playing a game. Initially, Alice has a string word = "a".
You are given a positive integer k.
Now Bob will ask Alice to perform the following operation forever:
Generate a new string by changing each character in word to its next character in the English alphabet, and append it to the original word.
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(k = 27) == \"d\"\n assert candidate(k = 1) == \"a\"\n assert candidate(k = 7) == \"c\"\n assert candidate(k = 500) == \"h\"\n assert candidate(k = 26) == \"d\"\n assert candidate(k = 5) == \"b\"\n assert candidate(k = 1... | {
"canonical_parameter_names": [
"k"
],
"leetcode_dataset_entry_point": "Solution().kthCharacter",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "char kthCharacter(int k) {",
"container": "Solution",
"callable": "kthCharacter",
"parameters": [
{
"name": "k",
"type": "int"
}
],
"return_type": "char",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,305 | count-of-substrings-containing-every-vowel-and-k-consonants-i | Medium | You are given a string word and a non-negative integer k.
Return the total number of substrings of word that contain every vowel ('a', 'e', 'i', 'o', and 'u') at least once and exactly k consonants.
Example 1:
Input: word = "aeioqq", k = 1
Output: 0
Explanation:
There is no substring with every vowel.
Example 2:
I... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word = \"uuuaaeiooouueiiaaoou\",k = 3) == 0\n assert candidate(word = \"aeiouaeiouaeiouaeiou\",k = 0) == 136\n assert candidate(word = \"aeiouzzzzz\",k = 5) == 1\n assert candidate(word = \"aeioqq\",k = 1) == 0\n assert candi... | {
"canonical_parameter_names": [
"word",
"k"
],
"leetcode_dataset_entry_point": "Solution().countOfSubstrings",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int countOfSubstrings(string word, int k) {",
"container": "Solution",
"callable": "countOfSubstrings",
"parameters": [
{
"name": "word",
"type": "string"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/co... |
3,306 | count-of-substrings-containing-every-vowel-and-k-consonants-ii | Medium | You are given a string word and a non-negative integer k.
Return the total number of substrings of word that contain every vowel ('a', 'e', 'i', 'o', and 'u') at least once and exactly k consonants.
Example 1:
Input: word = "aeioqq", k = 1
Output: 0
Explanation:
There is no substring with every vowel.
Example 2:
I... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnmaeiou\",k = 10) == 4\n assert candidate(word = \"uoieaouoieaouoieaouoieaoiueaouieaouieaouieao\",k = 4) == 0\n assert candidate(word = \"aeiouzzzzz\",k = 5) == 1\n assert candidate(word = \"aeio... | {
"canonical_parameter_names": [
"word",
"k"
],
"leetcode_dataset_entry_point": "Solution().countOfSubstrings",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long countOfSubstrings(string word, int k) {",
"container": "Solution",
"callable": "countOfSubstrings",
"parameters": [
{
"name": "word",
"type": "string"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "long long",
"signature_source": ... |
3,307 | find-the-k-th-character-in-string-game-ii | Hard | Alice and Bob are playing a game. Initially, Alice has a string word = "a".
You are given a positive integer k. You are also given an integer array operations, where operations[i] represents the type of the ith operation.
Now Bob will ask Alice to perform all operations in sequence:
If operations[i] == 0, append a cop... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(k = 20,operations = [1, 0, 1, 0, 1]) == \"c\"\n assert candidate(k = 15,operations = [1, 0, 1, 0]) == \"b\"\n assert candidate(k = 10,operations = [0, 1, 0, 1]) == \"b\"\n assert candidate(k = 3,operations = [0, 1]) == \"b\"\n ... | {
"canonical_parameter_names": [
"k",
"operations"
],
"leetcode_dataset_entry_point": "Solution().kthCharacter",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "char kthCharacter(long long k, vector<int>& operations) {",
"container": "Solution",
"callable": "kthCharacter",
"parameters": [
{
"name": "k",
"type": "long long"
},
{
"name": "operations",
"type": "vector<int>&"
}
],
"return_type": "char",
"sig... |
3,309 | maximum-possible-number-by-binary-concatenation | Medium | You are given an array of integers nums of size 3.
Return the maximum possible number whose binary representation can be formed by concatenating the binary representation of all elements in nums in some order.
Note that the binary representation of any number does not contain leading zeros.
Example 1:
Input: nums = ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [64, 1, 127]) == 32704\n assert candidate(nums = [7, 5, 3]) == 253\n assert candidate(nums = [127, 127, 127]) == 2097151\n assert candidate(nums = [32, 16, 8]) == 17440\n assert candidate(nums = [1, 5, 7]) == 125\n ... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maxGoodNumber",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int maxGoodNumber(vector<int>& nums) {",
"container": "Solution",
"callable": "maxGoodNumber",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,310 | remove-methods-from-project | Medium | You are maintaining a project that has n methods numbered from 0 to n - 1.
You are given two integers n and k, and a 2D integer array invocations, where invocations[i] = [ai, bi] indicates that method ai invokes method bi.
There is a known bug in method k. Method k, along with any method invoked by it, either directly ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 1,k = 0,invocations = []) == []\n assert candidate(n = 6,k = 2,invocations = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 4,k = 1,invocations = [[1, 2], [0, 1], [3, 2]]) == [0, 1, 2, 3]... | {
"canonical_parameter_names": [
"n",
"k",
"invocations"
],
"leetcode_dataset_entry_point": "Solution().remainingMethods",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> remainingMethods(int n, int k, vector<vector<int>>& invocations) {",
"container": "Solution",
"callable": "remainingMethods",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "k",
"type": "int"
},
{
"name": "invocations",... |
3,311 | construct-2d-grid-matching-graph-layout | Hard | You are given a 2D integer array edges representing an undirected graph having n nodes, where edges[i] = [ui, vi] denotes an edge between nodes ui and vi.
Construct a 2D grid that satisfies these conditions:
The grid contains all nodes from 0 to n - 1 in its cells, with each node appearing exactly once.
Two nodes shou... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 9,edges = [[0, 1], [0, 4], [0, 5], [1, 7], [2, 3], [2, 4], [2, 5], [3, 6], [4, 6], [4, 7], [6, 8], [7, 8]]) == [[8, 6, 3], [7, 4, 2], [1, 0, 5]]\n assert candidate(n = 4,edges = [[0, 1], [0, 2], [1, 3], [2, 3]]) == [[3, 1], [2, 0]... | {
"canonical_parameter_names": [
"n",
"edges"
],
"leetcode_dataset_entry_point": "Solution().constructGridLayout",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<vector<int>> constructGridLayout(int n, vector<vector<int>>& edges) {",
"container": "Solution",
"callable": "constructGridLayout",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "edges",
"type": "vector<vector<int>>&"
}
],
"retur... |
3,312 | sorted-gcd-pair-queries | Hard | You are given an integer array nums of length n and an integer array queries.
Let gcdPairs denote an array obtained by calculating the GCD of all possible pairs (nums[i], nums[j]), where 0 <= i < j < n, and then sorting these values in ascending order.
For each query queries[i], you need to find the element at index qu... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 10, 15, 20],queries = [0, 1, 2, 3, 4, 5, 6, 8]) == [5, 5, 5, 5, 5, 10, 21, 21]\n assert candidate(nums = [7, 14, 28, 35],queries = [0, 3, 5, 10]) == [7, 7, 14, 36]\n assert candidate(nums = [7, 14, 21, 28, 35],queries = ... | {
"canonical_parameter_names": [
"nums",
"queries"
],
"leetcode_dataset_entry_point": "Solution().gcdValues",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> gcdValues(vector<int>& nums, vector<long long>& queries) {",
"container": "Solution",
"callable": "gcdValues",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "queries",
"type": "vector<long long>&"
}
],
"return_ty... |
3,314 | construct-the-minimum-bitwise-array-i | Easy | You are given an array nums consisting of n prime integers.
You need to construct an array ans of length n, such that, for each index i, the bitwise OR of ans[i] and ans[i] + 1 is equal to nums[i], i.e. ans[i] OR (ans[i] + 1) == nums[i].
Additionally, you must minimize each value of ans[i] in the resulting array.
If it... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [3, 7, 11, 13]) == [1, 3, 9, 12]\n assert candidate(nums = [41, 43, 47, 53]) == [40, 41, 39, 52]\n assert candidate(nums = [2, 3, 5, 7]) == [-1, 1, 4, 3]\n assert candidate(nums = [11, 13, 31]) == [9, 12, 15]\n assert ... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().minBitwiseArray",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> minBitwiseArray(vector<int>& nums) {",
"container": "Solution",
"callable": "minBitwiseArray",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "vector<int>",
"signature_source": "leetcode/codeSnippets",
"type_source": "leet... |
3,315 | construct-the-minimum-bitwise-array-ii | Medium | You are given an array nums consisting of n prime integers.
You need to construct an array ans of length n, such that, for each index i, the bitwise OR of ans[i] and ans[i] + 1 is equal to nums[i], i.e. ans[i] OR (ans[i] + 1) == nums[i].
Additionally, you must minimize each value of ans[i] in the resulting array.
If it... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [41, 43, 47, 53]) == [40, 41, 39, 52]\n assert candidate(nums = [29, 37, 41, 43]) == [28, 36, 40, 41]\n assert candidate(nums = [2, 3, 5, 7]) == [-1, 1, 4, 3]\n assert candidate(nums = [11, 13, 31]) == [9, 12, 15]\n as... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().minBitwiseArray",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> minBitwiseArray(vector<int>& nums) {",
"container": "Solution",
"callable": "minBitwiseArray",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "vector<int>",
"signature_source": "leetcode/codeSnippets",
"type_source": "leet... |
3,316 | find-maximum-removals-from-source-string | Medium | You are given a string source of size n, a string pattern that is a subsequence of source, and a sorted integer array targetIndices that contains distinct numbers in the range [0, n - 1].
We define an operation as removing a character at an index idx from source such that:
idx is an element of targetIndices.
pattern r... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(source = \"abbaa\",pattern = \"aba\",targetIndices = [0, 1, 2]) == 1\n assert candidate(source = \"abracadabra\",pattern = \"abc\",targetIndices = [0, 1, 5, 7, 10]) == 3\n assert candidate(source = \"bcda\",pattern = \"d\",targetIn... | {
"canonical_parameter_names": [
"source",
"pattern",
"targetIndices"
],
"leetcode_dataset_entry_point": "Solution().maxRemovals",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int maxRemovals(string source, string pattern, vector<int>& targetIndices) {",
"container": "Solution",
"callable": "maxRemovals",
"parameters": [
{
"name": "source",
"type": "string"
},
{
"name": "pattern",
"type": "string"
},
{
"name": "tar... |
3,317 | find-the-number-of-possible-ways-for-an-event | Hard | You are given three integers n, x, and y.
An event is being held for n performers. When a performer arrives, they are assigned to one of the x stages. All performers assigned to the same stage will perform together as a band, though some stages might remain empty.
After all performances are completed, the jury will awa... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 500,x = 250,y = 250) == 604049962\n assert candidate(n = 6,x = 6,y = 6) == 150265836\n assert candidate(n = 4,x = 2,y = 4) == 232\n assert candidate(n = 500,x = 5,y = 20) == 955685646\n assert candidate(n = 100,x = 10,y =... | {
"canonical_parameter_names": [
"n",
"x",
"y"
],
"leetcode_dataset_entry_point": "Solution().numberOfWays",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int numberOfWays(int n, int x, int y) {",
"container": "Solution",
"callable": "numberOfWays",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "x",
"type": "int"
},
{
"name": "y",
"type": "int"
}
],
"return_type": "int... |
3,318 | find-x-sum-of-all-k-long-subarrays-i | Easy | You are given an array nums of n integers and two integers k and x.
The x-sum of an array is calculated by the following procedure:
Count the occurrences of all elements in the array.
Keep only the occurrences of the top x most frequent elements. If two elements have the same number of occurrences, the element with th... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4,x = 4) == [10, 14, 18, 22, 26, 30, 34]\n assert candidate(nums = [10, 20, 30, 40, 50],k = 1,x = 1) == [10, 20, 30, 40, 50]\n assert candidate(nums = [1, 1, 2, 2, 3, 4, 2, 3],k = 6,x = 2)... | {
"canonical_parameter_names": [
"nums",
"k",
"x"
],
"leetcode_dataset_entry_point": "Solution().findXSum",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> findXSum(vector<int>& nums, int k, int x) {",
"container": "Solution",
"callable": "findXSum",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
},
{
"name": "x",
"type": "int"
}
... |
3,319 | k-th-largest-perfect-subtree-size-in-binary-tree | Medium | You are given the root of a binary tree and an integer k.
Return an integer denoting the size of the kth largest perfect binary subtree, or -1 if it doesn't exist.
A perfect binary tree is a tree where all leaves are on the same level, and every parent has two children.
Example 1:
Input: root = [5,3,6,5,2,5,7,1,8,nu... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(root = tree_node([5, 3, 6, 5, 2, 5, 7, 1, 8, None, None, 6, 8]),k = 2) == 3\n assert candidate(root = tree_node([1, 2, 2, 3, 3, None, None, 4, 4, 4, 4]),k = 2) == 3\n assert candidate(root = tree_node([1, 2, 3, None, 4]),k = 3) == ... | {
"canonical_parameter_names": [
"root",
"k"
],
"leetcode_dataset_entry_point": "Solution().kthLargestPerfectSubtree",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int kthLargestPerfectSubtree(TreeNode* root, int k) {",
"container": "Solution",
"callable": "kthLargestPerfectSubtree",
"parameters": [
{
"name": "root",
"type": "TreeNode*"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_s... |
3,320 | count-the-number-of-winning-sequences | Hard | Alice and Bob are playing a fantasy battle game consisting of n rounds where they summon one of three magical creatures each round: a Fire Dragon, a Water Serpent, or an Earth Golem. In each round, players simultaneously summon their creature and are awarded points as follows:
If one player summons a Fire Dragon and t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"WFWFWFWFWFWFWFWFWFWF\") == 730500\n assert candidate(s = \"WFW\") == 6\n assert candidate(s = \"FWEFWEFW\") == 157\n assert candidate(s = \"FWFWFWFWFWFWFWFWFWFW\") == 730500\n assert candidate(s = \"EWE\") == 6\n ass... | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().countWinningSequences",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int countWinningSequences(string s) {",
"container": "Solution",
"callable": "countWinningSequences",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,321 | find-x-sum-of-all-k-long-subarrays-ii | Hard | You are given an array nums of n integers and two integers k and x.
The x-sum of an array is calculated by the following procedure:
Count the occurrences of all elements in the array.
Keep only the occurrences of the top x most frequent elements. If two elements have the same number of occurrences, the element with th... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4,x = 2) == [70, 90, 110, 130, 150, 170, 190]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],k = 3,x = 1) == [15, 15, 15, 15, 15]\n assert candidate(nums = [10, 20, 20, 10, 30, ... | {
"canonical_parameter_names": [
"nums",
"k",
"x"
],
"leetcode_dataset_entry_point": "Solution().findXSum",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<long long> findXSum(vector<int>& nums, int k, int x) {",
"container": "Solution",
"callable": "findXSum",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
},
{
"name": "x",
"type": "int"
... |
3,324 | find-the-sequence-of-strings-appeared-on-the-screen | Medium | You are given a string target.
Alice is going to type target on her computer using a special keyboard that has only two keys:
Key 1 appends the character "a" to the string on the screen.
Key 2 changes the last character of the string on the screen to its next character in the English alphabet. For example, "c" changes... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(target = \"abcdefg\") == ['a', 'aa', 'ab', 'aba', 'abb', 'abc', 'abca', 'abcb', 'abcc', 'abcd', 'abcda', 'abcdb', 'abcdc', 'abcdd', 'abcde', 'abcdea', 'abcdeb', 'abcdec', 'abcded', 'abcdee', 'abcdef', 'abcdefa', 'abcdefb', 'abcdefc', 'ab... | {
"canonical_parameter_names": [
"target"
],
"leetcode_dataset_entry_point": "Solution().stringSequence",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<string> stringSequence(string target) {",
"container": "Solution",
"callable": "stringSequence",
"parameters": [
{
"name": "target",
"type": "string"
}
],
"return_type": "vector<string>",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode... |
3,325 | count-substrings-with-k-frequency-characters-i | Medium | Given a string s and an integer k, return the total number of substrings of s where at least one character appears at least k times.
Example 1:
Input: s = "abacb", k = 2
Output: 4
Explanation:
The valid substrings are:
"aba" (character 'a' appears 2 times).
"abac" (character 'a' appears 2 times).
"abacb" (character... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"pqr\",k = 1) == 6\n assert candidate(s = \"aabbccc\",k = 3) == 5\n assert candidate(s = \"aaabb\",k = 3) == 3\n assert candidate(s = \"zzzzzz\",k = 4) == 6\n assert candidate(s = \"abcde\",k = 1) == 15\n assert candi... | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().numberOfSubstrings",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int numberOfSubstrings(string s, int k) {",
"container": "Solution",
"callable": "numberOfSubstrings",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSn... |
3,326 | minimum-division-operations-to-make-array-non-decreasing | Medium | You are given an integer array nums.
Any positive divisor of a natural number x that is strictly less than x is called a proper divisor of x. For example, 2 is a proper divisor of 4, while 6 is not a proper divisor of 6.
You are allowed to perform an operation any number of times on nums, where in each operation you se... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [2, 3, 4, 6, 9]) == 0\n assert candidate(nums = [9, 3, 1]) == -1\n assert candidate(nums = [1, 1, 1, 1]) == 0\n assert candidate(nums = [10, 5, 3]) == -1\n assert candidate(nums = [3, 9, 27]) == 0\n assert candidate... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().minOperations",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int minOperations(vector<int>& nums) {",
"container": "Solution",
"callable": "minOperations",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,327 | check-if-dfs-strings-are-palindromes | Hard | You are given a tree rooted at node 0, consisting of n nodes numbered from 0 to n - 1. The tree is represented by an array parent of size n, where parent[i] is the parent of node i. Since node 0 is the root, parent[0] == -1.
You are also given a string s of length n, where s[i] is the character assigned to node i.
Cons... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(parent = [-1, 0, 1, 2, 2],s = \"abcba\") == [False, False, False, True, True]\n assert candidate(parent = [-1, 0, 0, 1, 2],s = \"aaaab\") == [True, True, False, True, True]\n assert candidate(parent = [-1, 0, 0, 1, 1, 2, 2],s = \"a... | {
"canonical_parameter_names": [
"parent",
"s"
],
"leetcode_dataset_entry_point": "Solution().findAnswer",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<bool> findAnswer(vector<int>& parent, string s) {",
"container": "Solution",
"callable": "findAnswer",
"parameters": [
{
"name": "parent",
"type": "vector<int>&"
},
{
"name": "s",
"type": "string"
}
],
"return_type": "vector<bool>",
"signa... |
3,330 | find-the-original-typed-string-i | Easy | 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.
Although Alice tried to focus on her typing, she is aware that she may still have done this at most once.
You are given a string word, whi... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word = \"aaabbbccc\") == 7\n assert candidate(word = \"abbcccc\") == 5\n assert candidate(word = \"mississippi\") == 4\n assert candidate(word = \"zzzzzzz\") == 7\n assert candidate(word = \"zzzzzzzzzz\") == 10\n assert ca... | {
"canonical_parameter_names": [
"word"
],
"leetcode_dataset_entry_point": "Solution().possibleStringCount",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int possibleStringCount(string word) {",
"container": "Solution",
"callable": "possibleStringCount",
"parameters": [
{
"name": "word",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
3,331 | find-subtree-sizes-after-changes | Medium | You are given a tree rooted at node 0 that consists of n nodes numbered from 0 to n - 1. The tree is represented by an array parent of size n, where parent[i] is the parent of node i. Since node 0 is the root, parent[0] == -1.
You are also given a string s of length n, where s[i] is the character assigned to node i.
We... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(parent = [-1, 0, 1, 2, 3, 4],s = \"aaaaa\") == [5, 4, 3, 2, 1]\n assert candidate(parent = [-1, 0, 0, 0, 0],s = \"abcde\") == [5, 1, 1, 1, 1]\n assert candidate(parent = [-1, 0, 4, 0, 1],s = \"abbba\") == [5, 2, 1, 1, 1]\n asser... | {
"canonical_parameter_names": [
"parent",
"s"
],
"leetcode_dataset_entry_point": "Solution().findSubtreeSizes",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> findSubtreeSizes(vector<int>& parent, string s) {",
"container": "Solution",
"callable": "findSubtreeSizes",
"parameters": [
{
"name": "parent",
"type": "vector<int>&"
},
{
"name": "s",
"type": "string"
}
],
"return_type": "vector<int>"... |
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.
Ea... | {
"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... | {
"canonical_parameter_names": [
"n",
"k",
"stayScore",
"travelScore"
],
"leetcode_dataset_entry_point": "Solution().maxScore",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int maxScore(int n, int k, vector<vector<int>>& stayScore, vector<vector<int>>& travelScore) {",
"container": "Solution",
"callable": "maxScore",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "k",
"type": "int"
},
{
"name": "stayS... |
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.
Retur... | {
"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... | {
"canonical_parameter_names": [
"word",
"k"
],
"leetcode_dataset_entry_point": "Solution().possibleStringCount",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int possibleStringCount(string word, int k) {",
"container": "Solution",
"callable": "possibleStringCount",
"parameters": [
{
"name": "word",
"type": "string"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcod... |
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 score ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [10, 20, 30]) == 600\n assert candidate(nums = [100, 200, 300, 400]) == 120000\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... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maxScore",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long maxScore(vector<int>& nums) {",
"container": "Solution",
"callable": "maxScore",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "long long",
"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 exampl... | {
"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) =... | {
"canonical_parameter_names": [
"s",
"t"
],
"leetcode_dataset_entry_point": "Solution().lengthAfterTransformations",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int lengthAfterTransformations(string s, int t) {",
"container": "Solution",
"callable": "lengthAfterTransformations",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "t",
"type": "int"
}
],
"return_type": "int",
"signature_source": ... |
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 the el... | {
"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... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().subsequencePairCount",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int subsequencePairCount(vector<int>& nums) {",
"container": "Solution",
"callable": "subsequencePairCount",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/c... |
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 character... | {
"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... | {
"canonical_parameter_names": [
"s",
"t",
"nums"
],
"leetcode_dataset_entry_point": "Solution().lengthAfterTransformations",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int lengthAfterTransformations(string s, int t, vector<int>& nums) {",
"container": "Solution",
"callable": "lengthAfterTransformations",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "t",
"type": "int"
},
{
"name": "nums",
... |
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 ev... | {
"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... | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().isBalanced",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "bool isBalanced(string num) {",
"container": "Solution",
"callable": "isBalanced",
"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 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, 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... | {
"canonical_parameter_names": [
"moveTime"
],
"leetcode_dataset_entry_point": "Solution().minTimeToReach",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int minTimeToReach(vector<vector<int>>& moveTime) {",
"container": "Solution",
"callable": "minTimeToReach",
"parameters": [
{
"name": "moveTime",
"type": "vector<vector<int>>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source":... |
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,... | {
"canonical_parameter_names": [
"moveTime"
],
"leetcode_dataset_entry_point": "Solution().minTimeToReach",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int minTimeToReach(vector<vector<int>>& moveTime) {",
"container": "Solution",
"callable": "minTimeToReach",
"parameters": [
{
"name": "moveTime",
"type": "vector<vector<int>>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source":... |
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 ans... | {
"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... | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().countBalancedPermutations",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int countBalancedPermutations(string num) {",
"container": "Solution",
"callable": "countBalancedPermutations",
"parameters": [
{
"name": "num",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeS... |
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 tha... | {
"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 ... | {
"canonical_parameter_names": [
"n",
"t"
],
"leetcode_dataset_entry_point": "Solution().smallestNumber",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int smallestNumber(int n, int t) {",
"container": "Solution",
"callable": "smallestNumber",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "t",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"ty... |
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 frequency of... | {
"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... | {
"canonical_parameter_names": [
"nums",
"k",
"numOperations"
],
"leetcode_dataset_entry_point": "Solution().maxFrequency",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int maxFrequency(vector<int>& nums, int k, int numOperations) {",
"container": "Solution",
"callable": "maxFrequency",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
},
{
"name": "numOperations",
... |
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 frequency of... | {
"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 = [... | {
"canonical_parameter_names": [
"nums",
"k",
"numOperations"
],
"leetcode_dataset_entry_point": "Solution().maxFrequency",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int maxFrequency(vector<int>& nums, int k, int numOperations) {",
"container": "Solution",
"callable": "maxFrequency",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
},
{
"name": "numOperations",
... |
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 "-1"... | {
"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... | {
"canonical_parameter_names": [
"num",
"t"
],
"leetcode_dataset_entry_point": "Solution().smallestNumber",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "string smallestNumber(string num, long long t) {",
"container": "Solution",
"callable": "smallestNumber",
"parameters": [
{
"name": "num",
"type": "string"
},
{
"name": "t",
"type": "long long"
}
],
"return_type": "string",
"signature_source": "l... |
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] are ... | {
"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, ... | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().hasIncreasingSubarrays",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "bool hasIncreasingSubarrays(vector<int>& nums, int k) {",
"container": "Solution",
"callable": "hasIncreasingSubarrays",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "bool",
"signatu... |
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..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... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maxIncreasingSubarrays",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int maxIncreasingSubarrays(vector<int>& nums) {",
"container": "Solution",
"callable": "maxIncreasingSubarrays",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetco... |
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 109 + 7.
Note tha... | {
"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]) ... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().sumOfGoodSubsequences",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int sumOfGoodSubsequences(vector<int>& nums) {",
"container": "Solution",
"callable": "sumOfGoodSubsequences",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode... |
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 representati... | {
"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) ... | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().countKReducibleNumbers",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int countKReducibleNumbers(string s, int k) {",
"container": "Solution",
"callable": "countKReducibleNumbers",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcod... |
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 direction... | {
"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... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countValidSelections",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int countValidSelections(vector<int>& nums) {",
"container": "Solution",
"callable": "countValidSelections",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/c... |
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] = [li, ri].
For each queries[i]:
Select a subset of indices within the range [li, ri] 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 if it is po... | {
"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... | {
"canonical_parameter_names": [
"nums",
"queries"
],
"leetcode_dataset_entry_point": "Solution().isZeroArray",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "bool isZeroArray(vector<int>& nums, vector<vector<int>>& queries) {",
"container": "Solution",
"callable": "isZeroArray",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "queries",
"type": "vector<vector<int>>&"
}
],
"return_t... |
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] = [li, ri, vali].
Each queries[i] represents the following action on nums:
Decrement the value at each index in the range [li, ri] in nums by at most vali.
The amount by which each value is decremented can be chosen independently f... | {
"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,... | {
"canonical_parameter_names": [
"nums",
"queries"
],
"leetcode_dataset_entry_point": "Solution().minZeroArray",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int minZeroArray(vector<int>& nums, vector<vector<int>>& queries) {",
"container": "Solution",
"callable": "minZeroArray",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "queries",
"type": "vector<vector<int>>&"
}
],
"return_... |
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.
Gi... | {
"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) ... | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().canAliceWin",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "bool canAliceWin(int n) {",
"container": "Solution",
"callable": "canAliceWin",
"parameters": [
{
"name": "n",
"type": "int"
}
],
"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 costs n... | {
"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... | {
"canonical_parameter_names": [
"s",
"t",
"nextCost",
"previousCost"
],
"leetcode_dataset_entry_point": "Solution().shiftDistance",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long shiftDistance(string s, string t, vector<int>& nextCost, vector<int>& previousCost) {",
"container": "Solution",
"callable": "shiftDistance",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "t",
"type": "string"
},
{
"n... |
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] = [li, ri].
Each queries[i] represents the following action on nums:
Decrement the value at each index in the range [li, ri] in nums by at most 1.
The amount by which the value is decremented can be chosen independently for each in... | {
"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, ... | {
"canonical_parameter_names": [
"nums",
"queries"
],
"leetcode_dataset_entry_point": "Solution().maxRemoval",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int maxRemoval(vector<int>& nums, vector<vector<int>>& queries) {",
"container": "Solution",
"callable": "maxRemoval",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "queries",
"type": "vector<vector<int>>&"
}
],
"return_type... |
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 chil... | {
"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... | {
"canonical_parameter_names": [
"fruits"
],
"leetcode_dataset_entry_point": "Solution().maxCollectedFruits",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int maxCollectedFruits(vector<vector<int>>& fruits) {",
"container": "Solution",
"callable": "maxCollectedFruits",
"parameters": [
{
"name": "fruits",
"type": "vector<vector<int>>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_sour... |
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 e... | {
"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 ... | {
"canonical_parameter_names": [
"nums",
"l",
"r"
],
"leetcode_dataset_entry_point": "Solution().minimumSumSubarray",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int minimumSumSubarray(vector<int>& nums, int l, int r) {",
"container": "Solution",
"callable": "minimumSumSubarray",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "l",
"type": "int"
},
{
"name": "r",
"type": "i... |
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.
Return ... | {
"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... | {
"canonical_parameter_names": [
"s",
"t",
"k"
],
"leetcode_dataset_entry_point": "Solution().isPossibleToRearrange",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "bool isPossibleToRearrange(string s, string t, int k) {",
"container": "Solution",
"callable": "isPossibleToRearrange",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "t",
"type": "string"
},
{
"name": "k",
"type": "int"
... |
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: Cho... | {
"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... | {
"canonical_parameter_names": [
"nums",
"k",
"op1",
"op2"
],
"leetcode_dataset_entry_point": "Solution().minArraySum",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int minArraySum(vector<int>& nums, int k, int op1, int op2) {",
"container": "Solution",
"callable": "minArraySum",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
},
{
"name": "op1",
"type": "in... |
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] = [ui, vi, wi] indicates that there is an edge between nodes ui and vi with weight wi in the tree.
Your task is to remove zero or more edges such that:
Each node has an edge with at ... | {
"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]... | {
"canonical_parameter_names": [
"edges",
"k"
],
"leetcode_dataset_entry_point": "Solution().maximizeSumOfWeights",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "long long maximizeSumOfWeights(vector<vector<int>>& edges, int k) {",
"container": "Solution",
"callable": "maximizeSumOfWeights",
"parameters": [
{
"name": "edges",
"type": "vector<vector<int>>&"
},
{
"name": "k",
"type": "int"
}
],
"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 ... | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().smallestNumber",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int smallestNumber(int n) {",
"container": "Solution",
"callable": "smallestNumber",
"parameters": [
{
"name": "n",
"type": "int"
}
],
"return_type": "int",
"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 element... | {
"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... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().getLargestOutlier",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "int getLargestOutlier(vector<int>& nums) {",
"container": "Solution",
"callable": "getLargestOutlier",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSni... |
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] = [ai, bi] indicates that there is an edge between nodes ai and bi in the first tre... | {
"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... | {
"canonical_parameter_names": [
"edges1",
"edges2",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxTargetNodes",
"problem_source": "newfacade/LeetCodeDataset",
"interface_source": "leetcode/codeSnippets"
} | cpp | {
"raw_signature": "vector<int> maxTargetNodes(vector<vector<int>>& edges1, vector<vector<int>>& edges2, int k) {",
"container": "Solution",
"callable": "maxTargetNodes",
"parameters": [
{
"name": "edges1",
"type": "vector<vector<int>>&"
},
{
"name": "edges2",
"type": "vector... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.