[Java] ✅ 72MS ✅ 89% ✅ O(n *m) ✅ PREFIX XOR ✅ COUNTING SORT
Approach\n1. Use an int[2^20 - 1] to store a counting sort of all possible XORs. The max XOR for values of max 10^6 is 2^20 - 1. (20 1s).\n2. Perform a prefix X
# Approach\n1. Use an int[2^20 - 1] to store a counting sort of all possible XORs. The max XOR for values of max 10^6 is 2^20 - 1. (20 1s).\n2. Perform a prefix XOR for the matrix and store the value in the counting array.\n3. Starting from highest entry in counting xor, traverse back, decrementing k, stopping when k reaches 0. Return the stopping position.\n\n# Complexity\n- Time complexity:$$O(n * m)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public int kthLargestValue(int[][] matrix, int k) {\n        int[] xorCount = getXorCount(matrix);\n        return findKthLargestValue(xorCount, k);\n    }\n\n    private int[] getXorCount(int[][] matrix) {\n        int[] xorCount =  new int[1_059_000];\n        int[] topXor = new int[matrix[0].length];\n        topXor[0] = matrix[0][0];\n        xorCount[matrix[0][0]]++;\n        int[] currentXorRow = new int[matrix[0].length];\n        int currentXor = 0;\n        for (int j = 1; j < topXor.length; j++) {\n            topXor[j] = topXor[j-1] ^ matrix[0][j];\n            xorCount[topXor[j]]++;\n        }\n        for (int i = 1; i < matrix.length; i++) {\n            for (int j = 0; j < matrix[0].length; j++) {\n                currentXor = j == 0 ? matrix[i][j] : currentXor ^ matrix[i][j];\n                currentXorRow[j] = currentXor ^ topXor[j];\n                xorCount[currentXorRow[j]]++;\n            }\n            topXor = currentXorRow;\n        }\n        return xorCount;\n    }\n\n    private int findKthLargestValue(int[] xorCount, int k) {\n        int step;\n        for (int i = xorCount.length - 1; i >=0; i--) {\n            step = Math.min(xorCount[i], k);\n            xorCount[i] -= step;\n            k -= step;\n            if(k == 0) {\n                return i;\n            }\n        }\n        return -1;\n    }\n}\n```
['Java']