C++ Solution - Greedy Approach - XOR's Property
Property of XOR: A^A=0 (XOR of same number is Zero)\n\nclass Solution {\npublic:\n    int kthLargestValue(vector<vector<int>>& matrix, int k) {\n        int m=m
**Property of XOR:** A^A=0 (XOR of same number is Zero)\n```\nclass Solution {\npublic:\n    int kthLargestValue(vector<vector<int>>& matrix, int k) {\n        int m=matrix.size();\n        int n=matrix[0].size();\n        vector<int>ans(m*n);\n        vector<vector<int>>mat(m,vector<int>(n,0));\n        for(int i=0;i<m;i++)\n        {\n            for(int j=0;j<n;j++)\n            {\n                if(i==0 && j==0)\n                {\n                    mat[i][j]=matrix[i][j];\n                }\n                else if(i==0)\n                {\n                    mat[i][j]=mat[i][j-1]^matrix[i][j];\n                }\n                else if(j==0)\n                {\n                    mat[i][j]=mat[i-1][j]^matrix[i][j];\n                }\n                else\n                {\n                    mat[i][j]=mat[i][j-1]^mat[i-1][j-1]^mat[i-1][j]^matrix[i][j];\n                }\n            }\n        }\n        for(auto it1:mat)\n        {\n            for(auto it2:it1)\n            {\n                ans.push_back(it2);\n            }\n        }\n        sort(ans.begin(),ans.end(),greater<int>());\n        return ans[k-1];\n    }\n};\n```
[]