1738. Find Kth Largest XOR Coordinate Value
You are given a 2D matrix of size m x n, consisting of nonnegative integers. You are also given an integer k.
The value of coordinate (a, b) of the matrix is the XOR of all matrix[i][j] where 0 <= i <= a < m and 0 <= j <= b < n (0indexed).
Find the kth largest value (1indexed) of all the coordinates of matrix.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
 class Solution { public: int kthLargestValue(vector<vector<int>>& matrix, int k) { vector<int> A; int n = matrix.size(), m = matrix[0].size(); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(i) matrix[i][j] ^= matrix[i1][j]; if(j) matrix[i][j] ^= matrix[i][j1]; if(i and j) matrix[i][j] ^= matrix[i1][j1]; A.push_back(matrix[i][j]); } } sort(rbegin(A), rend(A)); return A[k1]; } };
