Detailed Explanation | C++ Solution | Easy Implementation
Solution:\n\nStep 1: Change the matrix so that matrix[i][j] will contain the xor of all the numbers in the ith row upto jth column as shown below.\n\n ---------
**Solution:**\n\nStep 1: Change the matrix so that matrix[i][j] will contain the xor of all the numbers in the ith row upto jth column as shown below.\n\n![image](https://assets.leetcode.com/users/images/39c6c67f-63da-44af-8899-84c5a4e21239_1611457938.8521633.png)  **---------->**  ![image](https://assets.leetcode.com/users/images/a1f2e8ad-36a5-492f-abd5-ec15ed4f8fd1_1611457955.8021202.png)\n\nStep 2:  Change the above created matrix so that matrix[i][j] will contain the xor of all the numbers in the jth column upto ith row as shown below.\n\n\n![image](https://assets.leetcode.com/users/images/57d6526c-216f-450e-b87c-06e715f56af3_1611458129.468142.png) **----->** ![image](https://assets.leetcode.com/users/images/1dec0d1d-6a5e-4a20-9578-efba40afd03c_1611458472.0484324.png)\n\nStep 3: In the above created matrix matrix[i][j] contains the xor value of submatrix from (0,0) to (i,j). Hence we can use below two ways to find the kth largest value. \n(Similar Problem - [[215] Kth Larges`t Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array/))\n\n           1.  Sort all the values and find the kth largest from that.\n           2.  Use a priority queue of size k and insert only if the new element is greater than the top of the queue\n\nI have used the second method.\nTime Complexity : ***O(NMlogK)***\n\n**Code:**\n```\nint kthLargestValue(vector<vector<int>>& matrix, int k) {\n        \n        int i, j, n = matrix.size(), m = matrix[0].size();\n        priority_queue< int, vector<int>, greater<int> >pq;\n        \n\t\t// Step 1\n        for(i = 0; i < n; i++)\n        {\n            for(j = 1; j < m; j++)\n            {\n                matrix[i][j] = matrix[i][j-1] ^ matrix[i][j];\n            }\n        }\n        \n\t\t// Step 2\n        for(i = 0; i < m; i++)\n        {\n            for(j = 1; j < n; j++)\n            {\n                matrix[j][i] = matrix[j-1][i] ^ matrix[j][i];\n            }\n        }\n        \n\t\t// Step 3\n        for(i = 0; i < n; i++)\n        {\n            for(j = 0; j < m; j++)\n            {\n                if(pq.size() < k)\n                    pq.push(matrix[i][j]);\n                else\n                {\n                   if(matrix[i][j] > pq.top())\n                   {\n                       pq.pop();\n                       pq.push(matrix[i][j]);\n                   }\n                }\n            }\n        }\n        \n        return pq.top();\n    }\n``
[]