Class Solution
- java.lang.Object
-
- g1701_1800.s1738_find_kth_largest_xor_coordinate_value.Solution
-
public class Solution extends Object
1738 - Find Kth Largest XOR Coordinate Value.Medium
You are given a 2D
matrixof sizem x n, consisting of non-negative integers. You are also given an integerk.The value of coordinate
(a, b)of the matrix is the XOR of allmatrix[i][j]where0 <= i <= a < mand0 <= j <= b < n(0-indexed).Find the
kthlargest value (1-indexed) of all the coordinates ofmatrix.Example 1:
Input: matrix = [[5,2],[1,6]], k = 1
Output: 7
Explanation: The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value.
Example 2:
Input: matrix = [[5,2],[1,6]], k = 2
Output: 5
Explanation: The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value.
Example 3:
Input: matrix = [[5,2],[1,6]], k = 3
Output: 4
Explanation: The value of coordinate (1,0) is 5 XOR 1 = 4, which is the 3rd largest value.
Constraints:
m == matrix.lengthn == matrix[i].length1 <= m, n <= 10000 <= matrix[i][j] <= 1061 <= k <= m * n
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intkthLargestValue(int[][] matrix, int k)
-