3134. Find the Median of the Uniqueness Array
You are given an integer array
nums. The uniqueness array ofnumsis the sorted array that contains the number of distinct elements of all the subarrays ofnums. In other words, it is a sorted array consisting ofdistinct(nums[i..j]), for all0 <= i <= j < nums.length.Here,
distinct(nums[i..j])denotes the number of distinct elements in the subarray that starts at indexiand ends at indexj.Return the median of the uniqueness array of
nums.Note that the median of an array is defined as the middle element of the array when it is sorted in non-decreasing order. If there are two choices for a median, the smaller of the two values is taken.
You are given two integers
nandx. You have to construct an array of positive integersnumsof sizenwhere for every0 <= i < n - 1,nums[i + 1]is greater thannums[i], and the result of the bitwiseANDoperation between all elements ofnumsisx.Return the minimum possible value of
nums[n - 1].
Find the Integer Added to Array II
You are given two integer arrays
nums1andnums2.From
nums1two elements have been removed, and all other elements have been increased (or decreased in the case of negative) by an integer, represented by the variablex.As a result,
nums1becomes equal tonums2. Two arrays are considered equal when they contain the same integers with the same frequencies.Return the minimum possible integer
xthat achieves this equivalence.
3131. Find the Integer Added to Array I
You are given two arrays of equal length,
nums1andnums2.Each element in
nums1has been increased (or decreased in the case of negative) by an integer, represented by the variablex.As a result,
nums1becomes equal tonums2. Two arrays are considered equal when they contain the same integers with the same frequencies.Return the integer
x.
3130. Find All Possible Stable Binary Arrays II
You are given 3 positive integers
zero,one, andlimit.A binary array
arris called stable if:
- The number of occurrences of 0 in
arris exactlyzero.- The number of occurrences of 1 in
arris exactlyone.- Each subarray of
arrwith a size greater thanlimitmust contain both 0 and 1.Return the total number of stable binary arrays.
Since the answer may be very large, return it modulo
109 + 7.
3129. Find All Possible Stable Binary Arrays I
You are given 3 positive integers
zero,one, andlimit.A binary array
arris called stable if:
- The number of occurrences of 0 in
arris exactlyzero.- The number of occurrences of 1 in
arris exactlyone.- Each subarray of
arrwith a size greater thanlimitmust contain both 0 and 1.Return the total number of stable binary arrays.
Since the answer may be very large, return it modulo
109 + 7.
You are given a 2D boolean matrix
grid.Return an integer that is the number of right triangles that can be made with the 3 elements of
gridsuch that all of them have a value of 1.Note:
- A collection of 3 elements of
gridis a right triangle if one of its elements is in the same row with another element and in the same column with the third element. The 3 elements do not have to be next to each other.
3127. Make a Square with the Same Color
You are given a 2D matrix
gridof size3 x 3consisting only of characters'B'and'W'. Character'W'represents the white color, and character'B'represents the black color.Your task is to change the color of at most one cell so that the matrix has a
2 x 2square where all cells are of the same color.Return
trueif it is possible to create a2 x 2square of the same color, otherwise, returnfalse.