problem stringlengths 20 3.95k | answer stringclasses 532
values | task stringclasses 6
values | problem_number int64 1 1.31k | set_number int64 1 5 |
|---|---|---|---|---|
You are given a 0-indexed string num representing a non-negative integer.
In one operation, you can pick any digit of num and delete it. Note that if you delete all the digits of num, num becomes 0.
Return the minimum number of operations required to make num special.
An integer x is considered special if it is divisib... | LiveCodeBench | 899 | 3 | |
You are given a 1-indexed array nums of n integers.
A set of numbers is complete if the product of every pair of its elements is a perfect square.
For a subset of the indices set {1, 2, ..., n} represented as {i_1, i_2, ..., i_k}, we define its element-sum as: nums[i_1] + nums[i_2] + ... + nums[i_k].
Return the maximum... | LiveCodeBench | 900 | 1 | |
You are given a 1-indexed array nums of n integers.
A set of numbers is complete if the product of every pair of its elements is a perfect square.
For a subset of the indices set {1, 2, ..., n} represented as {i_1, i_2, ..., i_k}, we define its element-sum as: nums[i_1] + nums[i_2] + ... + nums[i_k].
Return the maximum... | LiveCodeBench | 900 | 2 | |
You are given a 1-indexed array nums of n integers.
A set of numbers is complete if the product of every pair of its elements is a perfect square.
For a subset of the indices set {1, 2, ..., n} represented as {i_1, i_2, ..., i_k}, we define its element-sum as: nums[i_1] + nums[i_2] + ... + nums[i_k].
Return the maximum... | LiveCodeBench | 900 | 3 | |
You are given a binary string s that contains at least one '1'.
You have to rearrange the bits in such a way that the resulting binary number is the maximum odd binary number that can be created from this combination.
Return a string representing the maximum odd binary number that can be created from the given combinat... | LiveCodeBench | 901 | 1 | |
You are given a binary string s that contains at least one '1'.
You have to rearrange the bits in such a way that the resulting binary number is the maximum odd binary number that can be created from this combination.
Return a string representing the maximum odd binary number that can be created from the given combinat... | LiveCodeBench | 901 | 2 | |
You are given a binary string s that contains at least one '1'.
You have to rearrange the bits in such a way that the resulting binary number is the maximum odd binary number that can be created from this combination.
Return a string representing the maximum odd binary number that can be created from the given combinat... | LiveCodeBench | 901 | 3 | |
You are given an array nums consisting of non-negative integers.
We define the score of subarray nums[l..r] such that l <= r as nums[l] AND nums[l + 1] AND ... AND nums[r] where AND is the bitwise AND operation.
Consider splitting the array into one or more subarrays such that the following conditions are satisfied:
E... | LiveCodeBench | 902 | 1 | |
You are given an array nums consisting of non-negative integers.
We define the score of subarray nums[l..r] such that l <= r as nums[l] AND nums[l + 1] AND ... AND nums[r] where AND is the bitwise AND operation.
Consider splitting the array into one or more subarrays such that the following conditions are satisfied:
E... | LiveCodeBench | 902 | 2 | |
You are given an array nums consisting of non-negative integers.
We define the score of subarray nums[l..r] such that l <= r as nums[l] AND nums[l + 1] AND ... AND nums[r] where AND is the bitwise AND operation.
Consider splitting the array into one or more subarrays such that the following conditions are satisfied:
E... | LiveCodeBench | 902 | 3 | |
You are given a 0-indexed sorted array of integers nums.
You can perform the following operation any number of times:
Choose two indices, i and j, where i < j, such that nums[i] < nums[j].
Then, remove the elements at indices i and j from nums. The remaining elements retain their original order, and the array is re-in... | LiveCodeBench | 903 | 1 | |
You are given a 0-indexed sorted array of integers nums.
You can perform the following operation any number of times:
Choose two indices, i and j, where i < j, such that nums[i] < nums[j].
Then, remove the elements at indices i and j from nums. The remaining elements retain their original order, and the array is re-in... | LiveCodeBench | 903 | 2 | |
You are given a 0-indexed sorted array of integers nums.
You can perform the following operation any number of times:
Choose two indices, i and j, where i < j, such that nums[i] < nums[j].
Then, remove the elements at indices i and j from nums. The remaining elements retain their original order, and the array is re-in... | LiveCodeBench | 903 | 3 | |
You are given a 0-indexed array nums of non-negative integers, and two integers l and r.
Return the count of sub-multisets within nums where the sum of elements in each subset falls within the inclusive range of [l, r].
Since the answer may be large, return it modulo 10^9 + 7.
A sub-multiset is an unordered collection ... | LiveCodeBench | 904 | 1 | |
You are given a 0-indexed array nums of non-negative integers, and two integers l and r.
Return the count of sub-multisets within nums where the sum of elements in each subset falls within the inclusive range of [l, r].
Since the answer may be large, return it modulo 10^9 + 7.
A sub-multiset is an unordered collection ... | LiveCodeBench | 904 | 2 | |
You are given a 0-indexed array nums of non-negative integers, and two integers l and r.
Return the count of sub-multisets within nums where the sum of elements in each subset falls within the inclusive range of [l, r].
Since the answer may be large, return it modulo 10^9 + 7.
A sub-multiset is an unordered collection ... | LiveCodeBench | 904 | 3 | |
You are given a 0-indexed integer array nums and an integer k.
Return an integer that denotes the sum of elements in nums whose corresponding indices have exactly k set bits in their binary representation.
The set bits in an integer are the 1's present when it is written in binary.
For example, the binary representati... | LiveCodeBench | 905 | 1 | |
You are given a 0-indexed integer array nums and an integer k.
Return an integer that denotes the sum of elements in nums whose corresponding indices have exactly k set bits in their binary representation.
The set bits in an integer are the 1's present when it is written in binary.
For example, the binary representati... | LiveCodeBench | 905 | 2 | |
You are given a 0-indexed integer array nums and an integer k.
Return an integer that denotes the sum of elements in nums whose corresponding indices have exactly k set bits in their binary representation.
The set bits in an integer are the 1's present when it is written in binary.
For example, the binary representati... | LiveCodeBench | 905 | 3 | |
You are given a 0-indexed array nums consisting of positive integers.
There are two types of operations that you can apply on the array any number of times:
Choose two elements with equal values and delete them from the array.
Choose three elements with equal values and delete them from the array.
Return the minimum ... | LiveCodeBench | 906 | 1 | |
You are given a 0-indexed array nums consisting of positive integers.
There are two types of operations that you can apply on the array any number of times:
Choose two elements with equal values and delete them from the array.
Choose three elements with equal values and delete them from the array.
Return the minimum ... | LiveCodeBench | 906 | 2 | |
You are given a 0-indexed array nums consisting of positive integers.
There are two types of operations that you can apply on the array any number of times:
Choose two elements with equal values and delete them from the array.
Choose three elements with equal values and delete them from the array.
Return the minimum ... | LiveCodeBench | 906 | 3 | |
You are given a 0-indexed integer array nums of length n where n is the total number of students in the class. The class teacher tries to select a group of students so that all the students remain happy.
The i^th student will become happy if one of these two conditions is met:
The student is selected and the total num... | LiveCodeBench | 907 | 1 | |
You are given a 0-indexed integer array nums of length n where n is the total number of students in the class. The class teacher tries to select a group of students so that all the students remain happy.
The i^th student will become happy if one of these two conditions is met:
The student is selected and the total num... | LiveCodeBench | 907 | 2 | |
You are given a 0-indexed integer array nums of length n where n is the total number of students in the class. The class teacher tries to select a group of students so that all the students remain happy.
The i^th student will become happy if one of these two conditions is met:
The student is selected and the total num... | LiveCodeBench | 907 | 3 | |
You are given a 0-indexed array of integers nums, and an integer target.
Return the length of the longest subsequence of nums that sums up to target. If no such subsequence exists, return -1.
A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of t... | LiveCodeBench | 908 | 1 | |
You are given a 0-indexed array of integers nums, and an integer target.
Return the length of the longest subsequence of nums that sums up to target. If no such subsequence exists, return -1.
A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of t... | LiveCodeBench | 908 | 2 | |
You are given a 0-indexed array of integers nums, and an integer target.
Return the length of the longest subsequence of nums that sums up to target. If no such subsequence exists, return -1.
A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of t... | LiveCodeBench | 908 | 3 | |
You are given a 0-indexed array maxHeights of n integers.
You are tasked with building n towers in the coordinate line. The i^th tower is built at coordinate i and has a height of heights[i].
A configuration of towers is beautiful if the following conditions hold:
1 <= heights[i] <= maxHeights[i]
heights is a mountain... | LiveCodeBench | 909 | 1 | |
You are given a 0-indexed array maxHeights of n integers.
You are tasked with building n towers in the coordinate line. The i^th tower is built at coordinate i and has a height of heights[i].
A configuration of towers is beautiful if the following conditions hold:
1 <= heights[i] <= maxHeights[i]
heights is a mountain... | LiveCodeBench | 909 | 2 | |
You are given a 0-indexed array maxHeights of n integers.
You are tasked with building n towers in the coordinate line. The i^th tower is built at coordinate i and has a height of heights[i].
A configuration of towers is beautiful if the following conditions hold:
1 <= heights[i] <= maxHeights[i]
heights is a mountain... | LiveCodeBench | 909 | 3 | |
You are given a 0-indexed array nums and an integer target.
A 0-indexed array infinite_nums is generated by infinitely appending the elements of nums to itself.
Return the length of the shortest subarray of the array infinite_nums with a sum equal to target. If there is no such subarray return -1.
Example 1:
Input: ... | LiveCodeBench | 910 | 1 | |
You are given a 0-indexed array nums and an integer target.
A 0-indexed array infinite_nums is generated by infinitely appending the elements of nums to itself.
Return the length of the shortest subarray of the array infinite_nums with a sum equal to target. If there is no such subarray return -1.
Example 1:
Input: ... | LiveCodeBench | 910 | 2 | |
You are given a 0-indexed array nums and an integer target.
A 0-indexed array infinite_nums is generated by infinitely appending the elements of nums to itself.
Return the length of the shortest subarray of the array infinite_nums with a sum equal to target. If there is no such subarray return -1.
Example 1:
Input: ... | LiveCodeBench | 910 | 3 | |
You are given a binary string s and a positive integer k.
A substring of s is beautiful if the number of 1's in it is exactly k.
Let len be the length of the shortest beautiful substring.
Return the lexicographically smallest beautiful substring of string s with length equal to len. If s doesn't contain a beautiful sub... | LiveCodeBench | 911 | 1 | |
You are given a binary string s and a positive integer k.
A substring of s is beautiful if the number of 1's in it is exactly k.
Let len be the length of the shortest beautiful substring.
Return the lexicographically smallest beautiful substring of string s with length equal to len. If s doesn't contain a beautiful sub... | LiveCodeBench | 911 | 2 | |
You are given a binary string s and a positive integer k.
A substring of s is beautiful if the number of 1's in it is exactly k.
Let len be the length of the shortest beautiful substring.
Return the lexicographically smallest beautiful substring of string s with length equal to len. If s doesn't contain a beautiful sub... | LiveCodeBench | 911 | 3 | |
You have n processors each having 4 cores and n * 4 tasks that need to be executed such that each core should perform only one task.
Given a 0-indexed integer array processorTime representing the time at which each processor becomes available for the first time and a 0-indexed integer array tasks representing the time ... | LiveCodeBench | 912 | 1 | |
You have n processors each having 4 cores and n * 4 tasks that need to be executed such that each core should perform only one task.
Given a 0-indexed integer array processorTime representing the time at which each processor becomes available for the first time and a 0-indexed integer array tasks representing the time ... | LiveCodeBench | 912 | 2 | |
You have n processors each having 4 cores and n * 4 tasks that need to be executed such that each core should perform only one task.
Given a 0-indexed integer array processorTime representing the time at which each processor becomes available for the first time and a 0-indexed integer array tasks representing the time ... | LiveCodeBench | 912 | 3 | |
You are given a 0-indexed integer array nums and a positive integer k.
You can do the following operation on the array any number of times:
Choose any two distinct indices i and j and simultaneously update the values of nums[i] to (nums[i] AND nums[j]) and nums[j] to (nums[i] OR nums[j]). Here, OR denotes the bitwise ... | LiveCodeBench | 913 | 1 | |
You are given a 0-indexed integer array nums and a positive integer k.
You can do the following operation on the array any number of times:
Choose any two distinct indices i and j and simultaneously update the values of nums[i] to (nums[i] AND nums[j]) and nums[j] to (nums[i] OR nums[j]). Here, OR denotes the bitwise ... | LiveCodeBench | 913 | 2 | |
You are given a 0-indexed integer array nums and a positive integer k.
You can do the following operation on the array any number of times:
Choose any two distinct indices i and j and simultaneously update the values of nums[i] to (nums[i] AND nums[j]) and nums[j] to (nums[i] OR nums[j]). Here, OR denotes the bitwise ... | LiveCodeBench | 913 | 3 | |
You are given a 0-indexed integer array nums.
Return the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0.
The value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k].
Example 1:
Input: nums = [12,6,1,2,7]
Output:... | LiveCodeBench | 914 | 1 | |
You are given a 0-indexed integer array nums.
Return the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0.
The value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k].
Example 1:
Input: nums = [12,6,1,2,7]
Output:... | LiveCodeBench | 914 | 2 | |
You are given a 0-indexed integer array nums.
Return the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0.
The value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k].
Example 1:
Input: nums = [12,6,1,2,7]
Output:... | LiveCodeBench | 914 | 3 | |
You are given a 0-indexed integer array nums.
The distinct count of a subarray of nums is defined as:
Let nums[i..j] be a subarray of nums consisting of all the indices from i to j such that 0 <= i <= j < nums.length. Then the number of distinct values in nums[i..j] is called the distinct count of nums[i..j].
Return ... | LiveCodeBench | 915 | 1 | |
You are given a 0-indexed integer array nums.
The distinct count of a subarray of nums is defined as:
Let nums[i..j] be a subarray of nums consisting of all the indices from i to j such that 0 <= i <= j < nums.length. Then the number of distinct values in nums[i..j] is called the distinct count of nums[i..j].
Return ... | LiveCodeBench | 915 | 2 | |
You are given a 0-indexed integer array nums.
The distinct count of a subarray of nums is defined as:
Let nums[i..j] be a subarray of nums consisting of all the indices from i to j such that 0 <= i <= j < nums.length. Then the number of distinct values in nums[i..j] is called the distinct count of nums[i..j].
Return ... | LiveCodeBench | 915 | 3 | |
Given a 0-indexed array of strings words where words[i] is either a positive integer represented as a string or the string "prev".
Start iterating from the beginning of the array; for every "prev" string seen in words, find the last visited integer in words which is defined as follows:
Let k be the number of consecuti... | LiveCodeBench | 916 | 1 | |
Given a 0-indexed array of strings words where words[i] is either a positive integer represented as a string or the string "prev".
Start iterating from the beginning of the array; for every "prev" string seen in words, find the last visited integer in words which is defined as follows:
Let k be the number of consecuti... | LiveCodeBench | 916 | 2 | |
Given a 0-indexed array of strings words where words[i] is either a positive integer represented as a string or the string "prev".
Start iterating from the beginning of the array; for every "prev" string seen in words, find the last visited integer in words which is defined as follows:
Let k be the number of consecuti... | LiveCodeBench | 916 | 3 | |
You are given a 0-indexed integer array nums of length n.
We want to group the indices so for each index i in the range [0, n - 1], it is assigned to exactly one group.
A group assignment is valid if the following conditions hold:
For every group g, all indices i assigned to group g have the same value in nums.
For an... | LiveCodeBench | 917 | 1 | |
You are given a 0-indexed integer array nums of length n.
We want to group the indices so for each index i in the range [0, n - 1], it is assigned to exactly one group.
A group assignment is valid if the following conditions hold:
For every group g, all indices i assigned to group g have the same value in nums.
For an... | LiveCodeBench | 917 | 2 | |
You are given a 0-indexed integer array nums of length n.
We want to group the indices so for each index i in the range [0, n - 1], it is assigned to exactly one group.
A group assignment is valid if the following conditions hold:
For every group g, all indices i assigned to group g have the same value in nums.
For an... | LiveCodeBench | 917 | 3 | |
You are given two arrays nums1 and nums2 consisting of positive integers.
You have to replace all the 0's in both arrays with strictly positive integers such that the sum of elements of both arrays becomes equal.
Return the minimum equal sum you can obtain, or -1 if it is impossible.
Example 1:
Input: nums1 = [3,2,0... | LiveCodeBench | 918 | 1 | |
You are given two arrays nums1 and nums2 consisting of positive integers.
You have to replace all the 0's in both arrays with strictly positive integers such that the sum of elements of both arrays becomes equal.
Return the minimum equal sum you can obtain, or -1 if it is impossible.
Example 1:
Input: nums1 = [3,2,0... | LiveCodeBench | 918 | 2 | |
You are given two arrays nums1 and nums2 consisting of positive integers.
You have to replace all the 0's in both arrays with strictly positive integers such that the sum of elements of both arrays becomes equal.
Return the minimum equal sum you can obtain, or -1 if it is impossible.
Example 1:
Input: nums1 = [3,2,0... | LiveCodeBench | 918 | 3 | |
You are given positive integers n and m.
Define two integers, num1 and num2, as follows:
num1: The sum of all integers in the range [1, n] that are not divisible by m.
num2: The sum of all integers in the range [1, n] that are divisible by m.
Return the integer num1 - num2.
Example 1:
Input: n = 10, m = 3
Output: ... | LiveCodeBench | 919 | 1 | |
You are given positive integers n and m.
Define two integers, num1 and num2, as follows:
num1: The sum of all integers in the range [1, n] that are not divisible by m.
num2: The sum of all integers in the range [1, n] that are divisible by m.
Return the integer num1 - num2.
Example 1:
Input: n = 10, m = 3
Output: ... | LiveCodeBench | 919 | 2 | |
You are given positive integers n and m.
Define two integers, num1 and num2, as follows:
num1: The sum of all integers in the range [1, n] that are not divisible by m.
num2: The sum of all integers in the range [1, n] that are divisible by m.
Return the integer num1 - num2.
Example 1:
Input: n = 10, m = 3
Output: ... | LiveCodeBench | 919 | 3 | |
You are given a 0-indexed binary string s having an even length.
A string is beautiful if it's possible to partition it into one or more substrings such that:
Each substring has an even length.
Each substring contains only 1's or only 0's.
You can change any character in s to 0 or 1.
Return the minimum number of chan... | LiveCodeBench | 920 | 1 | |
You are given a 0-indexed binary string s having an even length.
A string is beautiful if it's possible to partition it into one or more substrings such that:
Each substring has an even length.
Each substring contains only 1's or only 0's.
You can change any character in s to 0 or 1.
Return the minimum number of chan... | LiveCodeBench | 920 | 2 | |
You are given a 0-indexed binary string s having an even length.
A string is beautiful if it's possible to partition it into one or more substrings such that:
Each substring has an even length.
Each substring contains only 1's or only 0's.
You can change any character in s to 0 or 1.
Return the minimum number of chan... | LiveCodeBench | 920 | 3 | |
You are given a 0-indexed array nums of integers.
A triplet of indices (i, j, k) is a mountain if:
i < j < k
nums[i] < nums[j] and nums[k] < nums[j]
Return the minimum possible sum of a mountain triplet of nums. If no such triplet exists, return -1.
Example 1:
Input: nums = [8,6,1,5,3]
Output: 9
Explanation: Tripl... | LiveCodeBench | 921 | 1 | |
You are given a 0-indexed array nums of integers.
A triplet of indices (i, j, k) is a mountain if:
i < j < k
nums[i] < nums[j] and nums[k] < nums[j]
Return the minimum possible sum of a mountain triplet of nums. If no such triplet exists, return -1.
Example 1:
Input: nums = [8,6,1,5,3]
Output: 9
Explanation: Tripl... | LiveCodeBench | 921 | 2 | |
You are given a 0-indexed array nums of integers.
A triplet of indices (i, j, k) is a mountain if:
i < j < k
nums[i] < nums[j] and nums[k] < nums[j]
Return the minimum possible sum of a mountain triplet of nums. If no such triplet exists, return -1.
Example 1:
Input: nums = [8,6,1,5,3]
Output: 9
Explanation: Tripl... | LiveCodeBench | 921 | 3 | |
You are given a 0-indexed integer array nums, and an integer k.
The K-or of nums is a non-negative integer that satisfies the following:
The i^th bit is set in the K-or if and only if there are at least k elements of nums in which bit i is set.
Return the K-or of nums.
Note that a bit i is set in x if (2^i AND x) ==... | LiveCodeBench | 922 | 1 | |
You are given a 0-indexed integer array nums, and an integer k.
The K-or of nums is a non-negative integer that satisfies the following:
The i^th bit is set in the K-or if and only if there are at least k elements of nums in which bit i is set.
Return the K-or of nums.
Note that a bit i is set in x if (2^i AND x) ==... | LiveCodeBench | 922 | 2 | |
You are given a 0-indexed integer array nums, and an integer k.
The K-or of nums is a non-negative integer that satisfies the following:
The i^th bit is set in the K-or if and only if there are at least k elements of nums in which bit i is set.
Return the K-or of nums.
Note that a bit i is set in x if (2^i AND x) ==... | LiveCodeBench | 922 | 3 | |
You are given a 0-indexed integer array nums.
A subsequence of nums having length k and consisting of indices i_0 < i_1 < ... < i_k-1 is balanced if the following holds:
nums[i_j] - nums[i_j-1] >= i_j - i_j-1, for every j in the range [1, k - 1].
A subsequence of nums having length 1 is considered balanced.
Return an... | LiveCodeBench | 923 | 1 | |
You are given a 0-indexed integer array nums.
A subsequence of nums having length k and consisting of indices i_0 < i_1 < ... < i_k-1 is balanced if the following holds:
nums[i_j] - nums[i_j-1] >= i_j - i_j-1, for every j in the range [1, k - 1].
A subsequence of nums having length 1 is considered balanced.
Return an... | LiveCodeBench | 923 | 2 | |
You are given a 0-indexed integer array nums.
A subsequence of nums having length k and consisting of indices i_0 < i_1 < ... < i_k-1 is balanced if the following holds:
nums[i_j] - nums[i_j-1] >= i_j - i_j-1, for every j in the range [1, k - 1].
A subsequence of nums having length 1 is considered balanced.
Return an... | LiveCodeBench | 923 | 3 | |
There are n teams numbered from 0 to n - 1 in a tournament.
Given a 0-indexed 2D boolean matrix grid of size n * n. For all i, j that 0 <= i, j <= n - 1 and i != j team i is stronger than team j if grid[i][j] == 1, otherwise, team j is stronger than team i.
Team a will be the champion of the tournament if there is no t... | LiveCodeBench | 924 | 1 | |
There are n teams numbered from 0 to n - 1 in a tournament.
Given a 0-indexed 2D boolean matrix grid of size n * n. For all i, j that 0 <= i, j <= n - 1 and i != j team i is stronger than team j if grid[i][j] == 1, otherwise, team j is stronger than team i.
Team a will be the champion of the tournament if there is no t... | LiveCodeBench | 924 | 2 | |
There are n teams numbered from 0 to n - 1 in a tournament.
Given a 0-indexed 2D boolean matrix grid of size n * n. For all i, j that 0 <= i, j <= n - 1 and i != j team i is stronger than team j if grid[i][j] == 1, otherwise, team j is stronger than team i.
Team a will be the champion of the tournament if there is no t... | LiveCodeBench | 924 | 3 | |
You are given two 0-indexed integer arrays, nums1 and nums2, both having length n.
You are allowed to perform a series of operations (possibly none).
In an operation, you select an index i in the range [0, n - 1] and swap the values of nums1[i] and nums2[i].
Your task is to find the minimum number of operations require... | LiveCodeBench | 925 | 1 | |
You are given two 0-indexed integer arrays, nums1 and nums2, both having length n.
You are allowed to perform a series of operations (possibly none).
In an operation, you select an index i in the range [0, n - 1] and swap the values of nums1[i] and nums2[i].
Your task is to find the minimum number of operations require... | LiveCodeBench | 925 | 2 | |
You are given two 0-indexed integer arrays, nums1 and nums2, both having length n.
You are allowed to perform a series of operations (possibly none).
In an operation, you select an index i in the range [0, n - 1] and swap the values of nums1[i] and nums2[i].
Your task is to find the minimum number of operations require... | LiveCodeBench | 925 | 3 | |
Given three integers a, b, and n, return the maximum value of (a XOR x) * (b XOR x) where 0 <= x < 2^n.
Since the answer may be too large, return it modulo 10^9 + 7.
Note that XOR is the bitwise XOR operation.
Example 1:
Input: a = 12, b = 5, n = 4
Output: 98
Explanation: For x = 2, (a XOR x) = 14 and (b XOR x) = 7.... | LiveCodeBench | 926 | 1 | |
Given three integers a, b, and n, return the maximum value of (a XOR x) * (b XOR x) where 0 <= x < 2^n.
Since the answer may be too large, return it modulo 10^9 + 7.
Note that XOR is the bitwise XOR operation.
Example 1:
Input: a = 12, b = 5, n = 4
Output: 98
Explanation: For x = 2, (a XOR x) = 14 and (b XOR x) = 7.... | LiveCodeBench | 926 | 2 | |
Given three integers a, b, and n, return the maximum value of (a XOR x) * (b XOR x) where 0 <= x < 2^n.
Since the answer may be too large, return it modulo 10^9 + 7.
Note that XOR is the bitwise XOR operation.
Example 1:
Input: a = 12, b = 5, n = 4
Output: 98
Explanation: For x = 2, (a XOR x) = 14 and (b XOR x) = 7.... | LiveCodeBench | 926 | 3 | |
You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:
|x - y| <= min(x, y)
You need to select two integers from nums such that they form a strong pair and their bitwise XOR is the maximum among all strong pairs in the array.
Return the maximum ... | LiveCodeBench | 927 | 1 | |
You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:
|x - y| <= min(x, y)
You need to select two integers from nums such that they form a strong pair and their bitwise XOR is the maximum among all strong pairs in the array.
Return the maximum ... | LiveCodeBench | 927 | 2 | |
You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:
|x - y| <= min(x, y)
You need to select two integers from nums such that they form a strong pair and their bitwise XOR is the maximum among all strong pairs in the array.
Return the maximum ... | LiveCodeBench | 927 | 3 | |
You are given a 0-indexed array of strings words and a character x.
Return an array of indices representing the words that contain the character x.
Note that the returned array may be in any order.
Example 1:
Input: words = ["leet","code"], x = "e"
Output: [0,1]
Explanation: "e" occurs in both words: "leet", and "co... | LiveCodeBench | 928 | 1 | |
You are given a 0-indexed array of strings words and a character x.
Return an array of indices representing the words that contain the character x.
Note that the returned array may be in any order.
Example 1:
Input: words = ["leet","code"], x = "e"
Output: [0,1]
Explanation: "e" occurs in both words: "leet", and "co... | LiveCodeBench | 928 | 2 | |
You are given a 0-indexed array of strings words and a character x.
Return an array of indices representing the words that contain the character x.
Note that the returned array may be in any order.
Example 1:
Input: words = ["leet","code"], x = "e"
Output: [0,1]
Explanation: "e" occurs in both words: "leet", and "co... | LiveCodeBench | 928 | 3 | |
There are n balls on a table, each ball has a color black or white.
You are given a 0-indexed binary string s of length n, where 1 and 0 represent black and white balls, respectively.
In each step, you can choose two adjacent balls and swap them.
Return the minimum number of steps to group all the black balls to the ri... | LiveCodeBench | 929 | 1 | |
There are n balls on a table, each ball has a color black or white.
You are given a 0-indexed binary string s of length n, where 1 and 0 represent black and white balls, respectively.
In each step, you can choose two adjacent balls and swap them.
Return the minimum number of steps to group all the black balls to the ri... | LiveCodeBench | 929 | 2 | |
There are n balls on a table, each ball has a color black or white.
You are given a 0-indexed binary string s of length n, where 1 and 0 represent black and white balls, respectively.
In each step, you can choose two adjacent balls and swap them.
Return the minimum number of steps to group all the black balls to the ri... | LiveCodeBench | 929 | 3 | |
You are given a 0-indexed integer array nums and an integer k.
You can perform the following operation on the array at most k times:
Choose any index i from the array and increase or decrease nums[i] by 1.
The score of the final array is the frequency of the most frequent element in the array.
Return the maximum scor... | LiveCodeBench | 930 | 1 | |
You are given a 0-indexed integer array nums and an integer k.
You can perform the following operation on the array at most k times:
Choose any index i from the array and increase or decrease nums[i] by 1.
The score of the final array is the frequency of the most frequent element in the array.
Return the maximum scor... | LiveCodeBench | 930 | 2 | |
You are given a 0-indexed integer array nums and an integer k.
You can perform the following operation on the array at most k times:
Choose any index i from the array and increase or decrease nums[i] by 1.
The score of the final array is the frequency of the most frequent element in the array.
Return the maximum scor... | LiveCodeBench | 930 | 3 | |
You are given two positive integers n and limit.
Return the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies.
Example 1:
Input: n = 5, limit = 2
Output: 3
Explanation: There are 3 ways to distribute 5 candies such that no child gets more than 2 candies: (1... | LiveCodeBench | 931 | 1 | |
You are given two positive integers n and limit.
Return the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies.
Example 1:
Input: n = 5, limit = 2
Output: 3
Explanation: There are 3 ways to distribute 5 candies such that no child gets more than 2 candies: (1... | LiveCodeBench | 931 | 2 | |
You are given two positive integers n and limit.
Return the total number of ways to distribute n candies among 3 children such that no child gets more than limit candies.
Example 1:
Input: n = 5, limit = 2
Output: 3
Explanation: There are 3 ways to distribute 5 candies such that no child gets more than 2 candies: (1... | LiveCodeBench | 931 | 3 | |
You are given an integer n.
A string s is called good if it contains only lowercase English characters and it is possible to rearrange the characters of s such that the new string contains "leet" as a substring.
For example:
The string "lteer" is good because we can rearrange it to form "leetr" .
"letl" is not good be... | LiveCodeBench | 932 | 1 | |
You are given an integer n.
A string s is called good if it contains only lowercase English characters and it is possible to rearrange the characters of s such that the new string contains "leet" as a substring.
For example:
The string "lteer" is good because we can rearrange it to form "leetr" .
"letl" is not good be... | LiveCodeBench | 932 | 2 | |
You are given an integer n.
A string s is called good if it contains only lowercase English characters and it is possible to rearrange the characters of s such that the new string contains "leet" as a substring.
For example:
The string "lteer" is good because we can rearrange it to form "leetr" .
"letl" is not good be... | LiveCodeBench | 932 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.