1738. Find Kth Largest XOR Coordinate Value
You are given a 2D matrix of size m x n, consisting of non-negative 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 (0-indexed). Find the kth largest value (1-indexed) of all the coordinates of matrix.
Matrix Block Sum
def kthLargestValue(self, matrix: List[List[int]], K: int) -> int:
R, C = len(matrix), len(matrix[0])
arr = []
for i in range(R):
for j in range(C):
if i and j:
matrix[i][j] ^= matrix[i-1][j]^matrix[i][j-1]^matrix[i-1][j-1]
elif i:
matrix[i][j] ^= matrix[i-1][j]
elif j:
matrix[i][j] ^= matrix[i][j-1]
arr.append(matrix[i][j])
arr.sort()
return arr[-K]