Single loop, O(k) space
\n\nint kthLargestValue(vector<vector<int>>& matrix, int k) {\n        int n = matrix.size();\n        int m = matrix[0].size();\n        priority_queue<int, ve
```\n\nint kthLargestValue(vector<vector<int>>& matrix, int k) {\n        int n = matrix.size();\n        int m = matrix[0].size();\n        priority_queue<int, vector<int>, greater<int>> pq;\n        for(int i = 0; i < n; i++)\n        {\n            for(int j = 0; j < m; j++)\n            {\n                if(j > 0)\n                    matrix[i][j] = matrix[i][j] ^ matrix[i][j - 1];\n                if(i > 0)\n                    matrix[i][j] = matrix[i][j] ^ matrix[i - 1][j];\n                if(i > 0 and j > 0)\n                    matrix[i][j] ^= matrix[i - 1][j - 1];\n                if(pq.size() < k)\n                    pq.push(matrix[i][j]);\n                else if(pq.top() < matrix[i][j])\n                {\n                    pq.pop();\n                    pq.push(matrix[i][j]);\n                }\n            }\n        }\n        return pq.top();\n    }\n\n\n```
[]