Prefix XOR + Heap || Explained
Complexity\n- Time complexity: O(mnlog(m*n)) \n\n- Space complexity: O(k) as min heap stores at most k elements only \n\n# Code\n\nclass Solution {\npublic:\n  
# Complexity\n- Time complexity: $$O(m*n*log(m*n))$$ \n\n- Space complexity: $$O(k)$$ as min heap stores at most k elements only \n\n# Code\n```\nclass Solution {\npublic:\n    int kthLargestValue(vector<vector<int>>& matrix, int k) {\n        int m = matrix.size(), n = matrix[0].size();\n        priority_queue<int,vector<int>,greater<int>> pq; //declare min heap\n        \n        //calculate row-wise prefix xor\n        for(int i=0; i<m; i++) {\n            for(int j=1; j<n; j++) {\n                matrix[i][j] ^= matrix[i][j-1];\n            }\n        }\n\n        //calculate column-wise prefix xor\n        for(int j=0; j<n; j++) {\n            for(int i=1; i<m; i++) {\n                matrix[i][j] ^= matrix[i-1][j];\n            }\n        }\n        \n       //now, matrix[i][j] stores xor of all elements in \n       //the sub-matrix starting from (0,0) and ending at (i,j)\n        for(int i=0; i<m; i++) {\n            for(int j=0; j<n; j++) {\n                pq.push(matrix[i][j]);\n                if(pq.size() > k) { //if min heap\'s size exceeds k\n                    pq.pop(); //pop from it as we want only k elements in pq\n                }\n            }\n        }\n     return pq.top(); //return the top-most element\n    }\n};\n```
['Heap (Priority Queue)', 'Prefix Sum', 'C++']