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 s having an even length n. You are also given a 0-indexed 2D integer array, queries, where queries[i] = [a_i, b_i, c_i, d_i]. For each query i, you are allowed to perform the following operations: Rearrange the characters within the substring s[a_i:b_i], where 0 <= a_i <= b_i < n / 2. ...
LiveCodeBench
933
1
You are given a 0-indexed string s having an even length n. You are also given a 0-indexed 2D integer array, queries, where queries[i] = [a_i, b_i, c_i, d_i]. For each query i, you are allowed to perform the following operations: Rearrange the characters within the substring s[a_i:b_i], where 0 <= a_i <= b_i < n / 2. ...
LiveCodeBench
933
2
You are given a 0-indexed string s having an even length n. You are also given a 0-indexed 2D integer array, queries, where queries[i] = [a_i, b_i, c_i, d_i]. For each query i, you are allowed to perform the following operations: Rearrange the characters within the substring s[a_i:b_i], where 0 <= a_i <= b_i < n / 2. ...
LiveCodeBench
933
3
You are given two 0-indexed integer arrays nums1 and nums2 of sizes n and m, respectively. Consider calculating the following values: The number of indices i such that 0 <= i < n and nums1[i] occurs at least once in nums2. The number of indices i such that 0 <= i < m and nums2[i] occurs at least once in nums1. Return...
LiveCodeBench
934
1
You are given two 0-indexed integer arrays nums1 and nums2 of sizes n and m, respectively. Consider calculating the following values: The number of indices i such that 0 <= i < n and nums1[i] occurs at least once in nums2. The number of indices i such that 0 <= i < m and nums2[i] occurs at least once in nums1. Return...
LiveCodeBench
934
2
You are given two 0-indexed integer arrays nums1 and nums2 of sizes n and m, respectively. Consider calculating the following values: The number of indices i such that 0 <= i < n and nums1[i] occurs at least once in nums2. The number of indices i such that 0 <= i < m and nums2[i] occurs at least once in nums1. Return...
LiveCodeBench
934
3
You are given three strings s1, s2, and s3. You have to perform the following operation on these three strings as many times as you want. In one operation you can choose one of these three strings such that its length is at least 2 and delete the rightmost character of it. Return the minimum number of operations you ne...
LiveCodeBench
935
1
You are given three strings s1, s2, and s3. You have to perform the following operation on these three strings as many times as you want. In one operation you can choose one of these three strings such that its length is at least 2 and delete the rightmost character of it. Return the minimum number of operations you ne...
LiveCodeBench
935
2
You are given three strings s1, s2, and s3. You have to perform the following operation on these three strings as many times as you want. In one operation you can choose one of these three strings such that its length is at least 2 and delete the rightmost character of it. Return the minimum number of operations you ne...
LiveCodeBench
935
3
You are at a fruit market with different types of exotic fruits on display. You are given a 1-indexed array prices, where prices[i] denotes the number of coins needed to purchase the i^th fruit. The fruit market has the following offer: If you purchase the i^th fruit at prices[i] coins, you can get the next i fruits f...
LiveCodeBench
936
1
You are at a fruit market with different types of exotic fruits on display. You are given a 1-indexed array prices, where prices[i] denotes the number of coins needed to purchase the i^th fruit. The fruit market has the following offer: If you purchase the i^th fruit at prices[i] coins, you can get the next i fruits f...
LiveCodeBench
936
2
You are at a fruit market with different types of exotic fruits on display. You are given a 1-indexed array prices, where prices[i] denotes the number of coins needed to purchase the i^th fruit. The fruit market has the following offer: If you purchase the i^th fruit at prices[i] coins, you can get the next i fruits f...
LiveCodeBench
936
3
You are given a string s and a positive integer k. Let vowels and consonants be the number of vowels and consonants in a string. A string is beautiful if: vowels == consonants. (vowels * consonants) % k == 0, in other terms the multiplication of vowels and consonants is divisible by k. Return the number of non-empty ...
LiveCodeBench
937
1
You are given a string s and a positive integer k. Let vowels and consonants be the number of vowels and consonants in a string. A string is beautiful if: vowels == consonants. (vowels * consonants) % k == 0, in other terms the multiplication of vowels and consonants is divisible by k. Return the number of non-empty ...
LiveCodeBench
937
2
You are given a string s and a positive integer k. Let vowels and consonants be the number of vowels and consonants in a string. A string is beautiful if: vowels == consonants. (vowels * consonants) % k == 0, in other terms the multiplication of vowels and consonants is divisible by k. Return the number of non-empty ...
LiveCodeBench
937
3
You are given a 0-indexed integer array nums. You can perform any number of operations, where each operation involves selecting a subarray of the array and replacing it with the sum of its elements. For example, if the given array is [1,3,5,6] and you select subarray [3,5] the array will convert to [1,8,6]. Return the ...
LiveCodeBench
938
1
You are given a 0-indexed integer array nums. You can perform any number of operations, where each operation involves selecting a subarray of the array and replacing it with the sum of its elements. For example, if the given array is [1,3,5,6] and you select subarray [3,5] the array will convert to [1,8,6]. Return the ...
LiveCodeBench
938
2
You are given a 0-indexed integer array nums. You can perform any number of operations, where each operation involves selecting a subarray of the array and replacing it with the sum of its elements. For example, if the given array is [1,3,5,6] and you select subarray [3,5] the array will convert to [1,8,6]. Return the ...
LiveCodeBench
938
3
You are given a 0-indexed array nums consisting of positive integers. A partition of an array into one or more contiguous subarrays is called good if no two subarrays contain the same number. Return the total number of good partitions of nums. Since the answer may be large, return it modulo 10^9 + 7. Example 1: Inpu...
LiveCodeBench
939
1
You are given a 0-indexed array nums consisting of positive integers. A partition of an array into one or more contiguous subarrays is called good if no two subarrays contain the same number. Return the total number of good partitions of nums. Since the answer may be large, return it modulo 10^9 + 7. Example 1: Inpu...
LiveCodeBench
939
2
You are given a 0-indexed array nums consisting of positive integers. A partition of an array into one or more contiguous subarrays is called good if no two subarrays contain the same number. Return the total number of good partitions of nums. Since the answer may be large, return it modulo 10^9 + 7. Example 1: Inpu...
LiveCodeBench
939
3
You are given an integer array nums and a positive integer k. Return the number of subarrays where the maximum element of nums appears at least k times in that subarray. A subarray is a contiguous sequence of elements within an array. Example 1: Input: nums = [1,3,2,3,3], k = 2 Output: 6 Explanation: The subarrays t...
LiveCodeBench
940
1
You are given an integer array nums and a positive integer k. Return the number of subarrays where the maximum element of nums appears at least k times in that subarray. A subarray is a contiguous sequence of elements within an array. Example 1: Input: nums = [1,3,2,3,3], k = 2 Output: 6 Explanation: The subarrays t...
LiveCodeBench
940
2
You are given an integer array nums and a positive integer k. Return the number of subarrays where the maximum element of nums appears at least k times in that subarray. A subarray is a contiguous sequence of elements within an array. Example 1: Input: nums = [1,3,2,3,3], k = 2 Output: 6 Explanation: The subarrays t...
LiveCodeBench
940
3
You are given a 0-indexed array of positive integers nums and a positive integer limit. In one operation, you can choose any two indices i and j and swap nums[i] and nums[j] if |nums[i] - nums[j]| <= limit. Return the lexicographically smallest array that can be obtained by performing the operation any number of times....
LiveCodeBench
941
1
You are given a 0-indexed array of positive integers nums and a positive integer limit. In one operation, you can choose any two indices i and j and swap nums[i] and nums[j] if |nums[i] - nums[j]| <= limit. Return the lexicographically smallest array that can be obtained by performing the operation any number of times....
LiveCodeBench
941
2
You are given a 0-indexed array of positive integers nums and a positive integer limit. In one operation, you can choose any two indices i and j and swap nums[i] and nums[j] if |nums[i] - nums[j]| <= limit. Return the lexicographically smallest array that can be obtained by performing the operation any number of times....
LiveCodeBench
941
3
You are given a 0-indexed integer array batteryPercentages having length n, denoting the battery percentages of n 0-indexed devices. Your task is to test each device i in order from 0 to n - 1, by performing the following test operations: If batteryPercentages[i] is greater than 0: Increment the count of tested dev...
LiveCodeBench
942
1
You are given a 0-indexed integer array batteryPercentages having length n, denoting the battery percentages of n 0-indexed devices. Your task is to test each device i in order from 0 to n - 1, by performing the following test operations: If batteryPercentages[i] is greater than 0: Increment the count of tested dev...
LiveCodeBench
942
2
You are given a 0-indexed integer array batteryPercentages having length n, denoting the battery percentages of n 0-indexed devices. Your task is to test each device i in order from 0 to n - 1, by performing the following test operations: If batteryPercentages[i] is greater than 0: Increment the count of tested dev...
LiveCodeBench
942
3
You are given a 0-indexed array mountain. Your task is to find all the peaks in the mountain array. Return an array that consists of indices of peaks in the given array in any order. Notes: A peak is defined as an element that is strictly greater than its neighboring elements. The first and last elements of the array ...
LiveCodeBench
943
1
You are given a 0-indexed array mountain. Your task is to find all the peaks in the mountain array. Return an array that consists of indices of peaks in the given array in any order. Notes: A peak is defined as an element that is strictly greater than its neighboring elements. The first and last elements of the array ...
LiveCodeBench
943
2
You are given a 0-indexed array mountain. Your task is to find all the peaks in the mountain array. Return an array that consists of indices of peaks in the given array in any order. Notes: A peak is defined as an element that is strictly greater than its neighboring elements. The first and last elements of the array ...
LiveCodeBench
943
3
You are given a string word and an integer k. A substring s of word is complete if: Each character in s occurs exactly k times. The difference between two adjacent characters is at most 2. That is, for any two adjacent characters c1 and c2 in s, the absolute difference in their positions in the alphabet is at most 2. ...
LiveCodeBench
944
1
You are given a string word and an integer k. A substring s of word is complete if: Each character in s occurs exactly k times. The difference between two adjacent characters is at most 2. That is, for any two adjacent characters c1 and c2 in s, the absolute difference in their positions in the alphabet is at most 2. ...
LiveCodeBench
944
2
You are given a string word and an integer k. A substring s of word is complete if: Each character in s occurs exactly k times. The difference between two adjacent characters is at most 2. That is, for any two adjacent characters c1 and c2 in s, the absolute difference in their positions in the alphabet is at most 2. ...
LiveCodeBench
944
3
You are given an integer n and a 0-indexed integer array sick which is sorted in increasing order. There are n children standing in a queue with positions 0 to n - 1 assigned to them. The array sick contains the positions of the children who are infected with an infectious disease. An infected child at position i can s...
LiveCodeBench
945
1
You are given an integer n and a 0-indexed integer array sick which is sorted in increasing order. There are n children standing in a queue with positions 0 to n - 1 assigned to them. The array sick contains the positions of the children who are infected with an infectious disease. An infected child at position i can s...
LiveCodeBench
945
2
You are given an integer n and a 0-indexed integer array sick which is sorted in increasing order. There are n children standing in a queue with positions 0 to n - 1 assigned to them. The array sick contains the positions of the children who are infected with an infectious disease. An infected child at position i can s...
LiveCodeBench
945
3
You are given an integer array nums and an integer k. The frequency of an element x is the number of times it occurs in an array. An array is called good if the frequency of each element in this array is less than or equal to k. Return the length of the longest good subarray of nums. A subarray is a contiguous non-empt...
LiveCodeBench
946
1
You are given an integer array nums and an integer k. The frequency of an element x is the number of times it occurs in an array. An array is called good if the frequency of each element in this array is less than or equal to k. Return the length of the longest good subarray of nums. A subarray is a contiguous non-empt...
LiveCodeBench
946
2
You are given an integer array nums and an integer k. The frequency of an element x is the number of times it occurs in an array. An array is called good if the frequency of each element in this array is less than or equal to k. Return the length of the longest good subarray of nums. A subarray is a contiguous non-empt...
LiveCodeBench
946
3
You are given a 0-indexed integer array nums of even length and there is also an empty array arr. Alice and Bob decided to play a game where in every round Alice and Bob will do one move. The rules of the game are as follows: Every round, first Alice will remove the minimum element from nums, and then Bob does the sam...
LiveCodeBench
947
1
You are given a 0-indexed integer array nums of even length and there is also an empty array arr. Alice and Bob decided to play a game where in every round Alice and Bob will do one move. The rules of the game are as follows: Every round, first Alice will remove the minimum element from nums, and then Bob does the sam...
LiveCodeBench
947
2
You are given a 0-indexed integer array nums of even length and there is also an empty array arr. Alice and Bob decided to play a game where in every round Alice and Bob will do one move. The rules of the game are as follows: Every round, first Alice will remove the minimum element from nums, and then Bob does the sam...
LiveCodeBench
947
3
You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n^2]. Each integer appears exactly once except a which appears twice and b which is missing. The task is to find the repeating and missing numbers a and b. Return a 0-indexed integer array ans of size 2 where ans[0] equals to a ...
LiveCodeBench
948
1
You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n^2]. Each integer appears exactly once except a which appears twice and b which is missing. The task is to find the repeating and missing numbers a and b. Return a 0-indexed integer array ans of size 2 where ans[0] equals to a ...
LiveCodeBench
948
2
You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n^2]. Each integer appears exactly once except a which appears twice and b which is missing. The task is to find the repeating and missing numbers a and b. Return a 0-indexed integer array ans of size 2 where ans[0] equals to a ...
LiveCodeBench
948
3
You are given two 0-indexed integer arrays nums1 and nums2 of even length n. You must remove n / 2 elements from nums1 and n / 2 elements from nums2. After the removals, you insert the remaining elements of nums1 and nums2 into a set s. Return the maximum possible size of the set s. Example 1: Input: nums1 = [1,2,1,...
LiveCodeBench
949
1
You are given two 0-indexed integer arrays nums1 and nums2 of even length n. You must remove n / 2 elements from nums1 and n / 2 elements from nums2. After the removals, you insert the remaining elements of nums1 and nums2 into a set s. Return the maximum possible size of the set s. Example 1: Input: nums1 = [1,2,1,...
LiveCodeBench
949
2
You are given two 0-indexed integer arrays nums1 and nums2 of even length n. You must remove n / 2 elements from nums1 and n / 2 elements from nums2. After the removals, you insert the remaining elements of nums1 and nums2 into a set s. Return the maximum possible size of the set s. Example 1: Input: nums1 = [1,2,1,...
LiveCodeBench
949
3
You are given a 0-indexed integer array nums having length n. You are allowed to perform a special move any number of times (including zero) on nums. In one special move you perform the following steps in order: Choose an index i in the range [0, n - 1], and a positive integer x. Add |nums[i] - x| to the total cost. C...
LiveCodeBench
950
1
You are given a 0-indexed integer array nums having length n. You are allowed to perform a special move any number of times (including zero) on nums. In one special move you perform the following steps in order: Choose an index i in the range [0, n - 1], and a positive integer x. Add |nums[i] - x| to the total cost. C...
LiveCodeBench
950
2
You are given a 0-indexed integer array nums having length n. You are allowed to perform a special move any number of times (including zero) on nums. In one special move you perform the following steps in order: Choose an index i in the range [0, n - 1], and a positive integer x. Add |nums[i] - x| to the total cost. C...
LiveCodeBench
950
3
You are given a 0-indexed string word. In one operation, you can pick any index i of word and change word[i] to any lowercase English letter. Return the minimum number of operations needed to remove all adjacent almost-equal characters from word. Two characters a and b are almost-equal if a == b or a and b are adjacent...
LiveCodeBench
951
1
You are given a 0-indexed string word. In one operation, you can pick any index i of word and change word[i] to any lowercase English letter. Return the minimum number of operations needed to remove all adjacent almost-equal characters from word. Two characters a and b are almost-equal if a == b or a and b are adjacent...
LiveCodeBench
951
2
You are given a 0-indexed string word. In one operation, you can pick any index i of word and change word[i] to any lowercase English letter. Return the minimum number of operations needed to remove all adjacent almost-equal characters from word. Two characters a and b are almost-equal if a == b or a and b are adjacent...
LiveCodeBench
951
3
You are given a 0-indexed integer array coins, representing the values of the coins available, and an integer target. An integer x is obtainable if there exists a subsequence of coins that sums to x. Return the minimum number of coins of any value that need to be added to the array so that every integer in the range [1...
LiveCodeBench
952
1
You are given a 0-indexed integer array coins, representing the values of the coins available, and an integer target. An integer x is obtainable if there exists a subsequence of coins that sums to x. Return the minimum number of coins of any value that need to be added to the array so that every integer in the range [1...
LiveCodeBench
952
2
You are given a 0-indexed integer array coins, representing the values of the coins available, and an integer target. An integer x is obtainable if there exists a subsequence of coins that sums to x. Return the minimum number of coins of any value that need to be added to the array so that every integer in the range [1...
LiveCodeBench
952
3
You are given a 0-indexed string s and an integer k. You are to perform the following partitioning operations until s is empty: Choose the longest prefix of s containing at most k distinct characters. Delete the prefix from s and increase the number of partitions by one. The remaining characters (if any) in s maintain...
LiveCodeBench
953
1
You are given a 0-indexed string s and an integer k. You are to perform the following partitioning operations until s is empty: Choose the longest prefix of s containing at most k distinct characters. Delete the prefix from s and increase the number of partitions by one. The remaining characters (if any) in s maintain...
LiveCodeBench
953
2
You are given a 0-indexed string s and an integer k. You are to perform the following partitioning operations until s is empty: Choose the longest prefix of s containing at most k distinct characters. Delete the prefix from s and increase the number of partitions by one. The remaining characters (if any) in s maintain...
LiveCodeBench
953
3
You are given a 0-indexed 2D array variables where variables[i] = [a_i, b_i, c_i, m_i], and an integer target. An index i is good if the following formula holds: 0 <= i < variables.length ((a_i^bi % 10)^ci) % m_i == target Return an array consisting of good indices in any order. Example 1: Input: variables = [[2,3...
LiveCodeBench
954
1
You are given a 0-indexed 2D array variables where variables[i] = [a_i, b_i, c_i, m_i], and an integer target. An index i is good if the following formula holds: 0 <= i < variables.length ((a_i^bi % 10)^ci) % m_i == target Return an array consisting of good indices in any order. Example 1: Input: variables = [[2,3...
LiveCodeBench
954
2
You are given a 0-indexed 2D array variables where variables[i] = [a_i, b_i, c_i, m_i], and an integer target. An index i is good if the following formula holds: 0 <= i < variables.length ((a_i^bi % 10)^ci) % m_i == target Return an array consisting of good indices in any order. Example 1: Input: variables = [[2,3...
LiveCodeBench
954
3
You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters. You are also given two 0-indexed character arrays original and changed, and an integer array cost, where cost[i] represents the cost of changing the character original[i] to the character changed[i]. You...
LiveCodeBench
955
1
You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters. You are also given two 0-indexed character arrays original and changed, and an integer array cost, where cost[i] represents the cost of changing the character original[i] to the character changed[i]. You...
LiveCodeBench
955
2
You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters. You are also given two 0-indexed character arrays original and changed, and an integer array cost, where cost[i] represents the cost of changing the character original[i] to the character changed[i]. You...
LiveCodeBench
955
3
You are given a 0-indexed array of integers nums. A prefix nums[0..i] is sequential if, for all 1 <= j <= i, nums[j] = nums[j - 1] + 1. In particular, the prefix consisting only of nums[0] is sequential. Return the smallest integer x missing from nums such that x is greater than or equal to the sum of the longest seque...
LiveCodeBench
956
1
You are given a 0-indexed array of integers nums. A prefix nums[0..i] is sequential if, for all 1 <= j <= i, nums[j] = nums[j - 1] + 1. In particular, the prefix consisting only of nums[0] is sequential. Return the smallest integer x missing from nums such that x is greater than or equal to the sum of the longest seque...
LiveCodeBench
956
2
You are given a 0-indexed array of integers nums. A prefix nums[0..i] is sequential if, for all 1 <= j <= i, nums[j] = nums[j - 1] + 1. In particular, the prefix consisting only of nums[0] is sequential. Return the smallest integer x missing from nums such that x is greater than or equal to the sum of the longest seque...
LiveCodeBench
956
3
You are given two positive integers x and y. In one operation, you can do one of the four following operations: Divide x by 11 if x is a multiple of 11. Divide x by 5 if x is a multiple of 5. Decrement x by 1. Increment x by 1. Return the minimum number of operations required to make x and y equal. Example 1: Inp...
LiveCodeBench
957
1
You are given two positive integers x and y. In one operation, you can do one of the four following operations: Divide x by 11 if x is a multiple of 11. Divide x by 5 if x is a multiple of 5. Decrement x by 1. Increment x by 1. Return the minimum number of operations required to make x and y equal. Example 1: Inp...
LiveCodeBench
957
2
You are given two positive integers x and y. In one operation, you can do one of the four following operations: Divide x by 11 if x is a multiple of 11. Divide x by 5 if x is a multiple of 5. Decrement x by 1. Increment x by 1. Return the minimum number of operations required to make x and y equal. Example 1: Inp...
LiveCodeBench
957
3
You are given an integer k and an integer x. Consider s is the 1-indexed binary representation of an integer num. The price of a number num is the number of i's such that i % x == 0 and s[i] is a set bit. Return the greatest integer num such that the sum of prices of all numbers from 1 to num is less than or equal to k...
LiveCodeBench
958
1
You are given an integer k and an integer x. Consider s is the 1-indexed binary representation of an integer num. The price of a number num is the number of i's such that i % x == 0 and s[i] is a set bit. Return the greatest integer num such that the sum of prices of all numbers from 1 to num is less than or equal to k...
LiveCodeBench
958
2
You are given an integer k and an integer x. Consider s is the 1-indexed binary representation of an integer num. The price of a number num is the number of i's such that i % x == 0 and s[i] is a set bit. Return the greatest integer num such that the sum of prices of all numbers from 1 to num is less than or equal to k...
LiveCodeBench
958
3
You are given an array nums consisting of positive integers. Return the total frequencies of elements in nums such that those elements all have the maximum frequency. The frequency of an element is the number of occurrences of that element in the array. Example 1: Input: nums = [1,2,2,3,1,4] Output: 4 Explanation: T...
LiveCodeBench
959
1
You are given an array nums consisting of positive integers. Return the total frequencies of elements in nums such that those elements all have the maximum frequency. The frequency of an element is the number of occurrences of that element in the array. Example 1: Input: nums = [1,2,2,3,1,4] Output: 4 Explanation: T...
LiveCodeBench
959
2
You are given an array nums consisting of positive integers. Return the total frequencies of elements in nums such that those elements all have the maximum frequency. The frequency of an element is the number of occurrences of that element in the array. Example 1: Input: nums = [1,2,2,3,1,4] Output: 4 Explanation: T...
LiveCodeBench
959
3
You are given three integers start, finish, and limit. You are also given a 0-indexed string s representing a positive integer. A positive integer x is called powerful if it ends with s (in other words, s is a suffix of x) and each digit in x is at most limit. Return the total number of powerful integers in the range [...
LiveCodeBench
960
1
You are given three integers start, finish, and limit. You are also given a 0-indexed string s representing a positive integer. A positive integer x is called powerful if it ends with s (in other words, s is a suffix of x) and each digit in x is at most limit. Return the total number of powerful integers in the range [...
LiveCodeBench
960
2
You are given three integers start, finish, and limit. You are also given a 0-indexed string s representing a positive integer. A positive integer x is called powerful if it ends with s (in other words, s is a suffix of x) and each digit in x is at most limit. Return the total number of powerful integers in the range [...
LiveCodeBench
960
3
You are given a 0-indexed integer array nums containing positive integers. Your task is to minimize the length of nums by performing the following operations any number of times (including zero): Select two distinct indices i and j from nums, such that nums[i] > 0 and nums[j] > 0. Insert the result of nums[i] % nums[j...
LiveCodeBench
961
1
You are given a 0-indexed integer array nums containing positive integers. Your task is to minimize the length of nums by performing the following operations any number of times (including zero): Select two distinct indices i and j from nums, such that nums[i] > 0 and nums[j] > 0. Insert the result of nums[i] % nums[j...
LiveCodeBench
961
2
You are given a 0-indexed integer array nums containing positive integers. Your task is to minimize the length of nums by performing the following operations any number of times (including zero): Select two distinct indices i and j from nums, such that nums[i] > 0 and nums[j] > 0. Insert the result of nums[i] % nums[j...
LiveCodeBench
961
3
You are given a 0-indexed string s, a string a, a string b, and an integer k. An index i is beautiful if: 0 <= i <= s.length - a.length s[i..(i + a.length - 1)] == a There exists an index j such that: 0 <= j <= s.length - b.length s[j..(j + b.length - 1)] == b |j - i| <= k Return the array that contains beautiful...
LiveCodeBench
962
1
You are given a 0-indexed string s, a string a, a string b, and an integer k. An index i is beautiful if: 0 <= i <= s.length - a.length s[i..(i + a.length - 1)] == a There exists an index j such that: 0 <= j <= s.length - b.length s[j..(j + b.length - 1)] == b |j - i| <= k Return the array that contains beautiful...
LiveCodeBench
962
2
You are given a 0-indexed string s, a string a, a string b, and an integer k. An index i is beautiful if: 0 <= i <= s.length - a.length s[i..(i + a.length - 1)] == a There exists an index j such that: 0 <= j <= s.length - b.length s[j..(j + b.length - 1)] == b |j - i| <= k Return the array that contains beautiful...
LiveCodeBench
962
3
You are given an array of positive integers nums. You have to check if it is possible to select two or more elements in the array such that the bitwise OR of the selected elements has at least one trailing zero in its binary representation. For example, the binary representation of 5, which is "101", does not have any ...
LiveCodeBench
963
1
You are given an array of positive integers nums. You have to check if it is possible to select two or more elements in the array such that the bitwise OR of the selected elements has at least one trailing zero in its binary representation. For example, the binary representation of 5, which is "101", does not have any ...
LiveCodeBench
963
2
You are given an array of positive integers nums. You have to check if it is possible to select two or more elements in the array such that the bitwise OR of the selected elements has at least one trailing zero in its binary representation. For example, the binary representation of 5, which is "101", does not have any ...
LiveCodeBench
963
3
You are given a 0-indexed integer array nums and a positive integer k. You can apply the following operation on the array any number of times: Choose any element of the array and flip a bit in its binary representation. Flipping a bit means changing a 0 to 1 or vice versa. Return the minimum number of operations requ...
LiveCodeBench
964
1
You are given a 0-indexed integer array nums and a positive integer k. You can apply the following operation on the array any number of times: Choose any element of the array and flip a bit in its binary representation. Flipping a bit means changing a 0 to 1 or vice versa. Return the minimum number of operations requ...
LiveCodeBench
964
2
You are given a 0-indexed integer array nums and a positive integer k. You can apply the following operation on the array any number of times: Choose any element of the array and flip a bit in its binary representation. Flipping a bit means changing a 0 to 1 or vice versa. Return the minimum number of operations requ...
LiveCodeBench
964
3
You are given a 2D 0-indexed integer array dimensions. For all indices i, 0 <= i < dimensions.length, dimensions[i][0] represents the length and dimensions[i][1] represents the width of the rectangle i. Return the area of the rectangle having the longest diagonal. If there are multiple rectangles with the longest diago...
LiveCodeBench
965
1
You are given a 2D 0-indexed integer array dimensions. For all indices i, 0 <= i < dimensions.length, dimensions[i][0] represents the length and dimensions[i][1] represents the width of the rectangle i. Return the area of the rectangle having the longest diagonal. If there are multiple rectangles with the longest diago...
LiveCodeBench
965
2
You are given a 2D 0-indexed integer array dimensions. For all indices i, 0 <= i < dimensions.length, dimensions[i][0] represents the length and dimensions[i][1] represents the width of the rectangle i. Return the area of the rectangle having the longest diagonal. If there are multiple rectangles with the longest diago...
LiveCodeBench
965
3
You are given a 0-indexed array of positive integers nums. A subarray of nums is called incremovable if nums becomes strictly increasing on removing the subarray. For example, the subarray [3, 4] is an incremovable subarray of [5, 3, 4, 6, 7] because removing this subarray changes the array [5, 3, 4, 6, 7] to [5, 6, 7]...
LiveCodeBench
966
1