3077. Maximum Strength of K Disjoint Subarrays
You are given a 0-indexed array of integers
numsof lengthn, and a positive odd integerk.The strength of
xsubarrays is defined asstrength = sum[1] * x - sum[2] * (x - 1) + sum[3] * (x - 2) - sum[4] * (x - 3) + ... + sum[x] * 1wheresum[i]is the sum of the elements in theithsubarray. Formally, strength is sum of(-1)i+1 * sum[i] * (x - i + 1)over alli‘s such that1 <= i <= x.You need to select
kdisjoint subarrays fromnums, such that their strength is maximum.Return the maximum possible strength that can be obtained.
Note that the selected subarrays don’t need to cover the entire array.
3076. Shortest Uncommon Substring in an Array
You are given an array
arrof sizenconsisting of non-empty strings.Find a string array
answerof sizensuch that:
answer[i]is the shortest substring ofarr[i]that does not occur as a substring in any other string inarr. If multiple such substrings exist,answer[i]should be the lexicographically smallest. And if no such substring exists,answer[i]should be an empty string.Return the array
answer.
3075. Maximize Happiness of Selected Children
You are given an array
happinessof lengthn, and a positive integerk.There are
nchildren standing in a queue, where theithchild has happiness valuehappiness[i]. You want to selectkchildren from thesenchildren inkturns.In each turn, when you select a child, the happiness value of all the children that have not been selected till now decreases by
1. Note that the happiness value cannot become negative and gets decremented only if it is positive.Return the maximum sum of the happiness values of the selected children you can achieve by selecting
kchildren.
3074. Apple Redistribution into Boxes
You are given an array
appleof sizenand an arraycapacityof sizem.There are
npacks where theithpack containsapple[i]apples. There aremboxes as well, and theithbox has a capacity ofcapacity[i]apples.Return the minimum number of boxes you need to select to redistribute these
npacks of apples into boxes.Note that, apples from the same pack can be distributed into different boxes.
3064. Guess the Number Using Bitwise Questions I
There is a number
nthat you have to find.There is also a pre-defined API
int commonSetBits(int num), which returns the number of bits where bothnandnumare1in that position of their binary representation. In other words, it returns the number of set bits inn & num, where&is the bitwiseANDoperator.Return the number
n.
349. Intersection of Two Arrays
Given two integer arrays
nums1andnums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order.