Simple XOR
Intuition\nxor[i][j] = xor[i-1][j-1]^xor[i][j-1]^xor[i-1][j]^mat[i][j];\n\n\n# Complexity\n- Time complexity:\nO(mn)\n\n- Space complexity:\nO(mn)\n\n# Code\ncp
# Intuition\nxor[i][j] = xor[i-1][j-1]^xor[i][j-1]^xor[i-1][j]^mat[i][j];\n\n\n# Complexity\n- Time complexity:\nO(m*n)\n\n- Space complexity:\nO(m*n)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int kthLargestValue(vector<vector<int>>& mat, int k) {\n\n        int n = mat.size();\n        int m = mat[0].size();\n        vector<vector<int>>xc(n, vector<int>(m,0));\n        vector<int>res;\n        for(int i = 0;i<n;i++){\n            for(int j = 0;j<m;j++){\n                if(i == 0 && j == 0){\n                    xc[i][j] = mat[i][j];\n                }else if(j == 0){\n                    xc[i][j] = xc[i-1][j] ^ mat[i][j];\n                }else if(i == 0){\n                    xc[i][j] = xc[i][j-1]^ mat[i][j];\n                }else {\n                    xc[i][j] = xc[i-1][j-1] ^ xc[i-1][j] ^ xc[i][j-1] ^ mat[i][j];\n                }\n\n                res.push_back(xc[i][j]);\n            }\n        }\n\n        sort(res.begin(),res.end(),greater<int>());\n\n\n        return res[k-1];\n        \n    }\n};\n```
['C++']