2965. Find Missing and Repeated Values
You are given a 0-indexed 2D integer matrix
gridof sizen * nwith values in the range[1, n2]. Each integer appears exactly once exceptawhich appears twice andbwhich is missing. The task is to find the repeating and missing numbersaandb.Return a 0-indexed integer array
ansof size2whereans[0]equals toaandans[1]equals tob.
2966. Divide Array Into Arrays With Max Difference
You are given an integer array
numsof sizenand a positive integerk.Divide the array into one or more arrays of size
3satisfying the following conditions:
- Each element of
numsshould be in exactly one array.- The difference between any two elements in one array is less than or equal to
k.Return a 2D array containing all the arrays. If it is impossible to satisfy the conditions, return an empty array. And if there are multiple answers, return any of them.
2967. Minimum Cost to Make Array Equalindromic
You are given a 0-indexed integer array
numshaving lengthn.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
iin the range[0, n - 1], and a positive integerx.- Add
|nums[i] - x|to the total cost.- Change the value of
nums[i]tox.A palindromic number is a positive integer that remains the same when its digits are reversed. For example,
121,2552and65756are palindromic numbers whereas24,46,235are not palindromic numbers.An array is considered equalindromic if all the elements in the array are equal to an integer
y, whereyis a palindromic number less than109.Return an integer denoting the minimum possible total cost to make
nums*equalindromic by performing any number of special moves.*
2968. Apply Operations to Maximize Frequency Score
You are given a 0-indexed integer array
numsand an integerk.You can perform the following operation on the array at most
ktimes:
- Choose any index
ifrom the array and increase or decreasenums[i]by1.The score of the final array is the frequency of the most frequent element in the array.
Return the maximum score you can achieve.
The frequency of an element is the number of occurences of that element in the array.