The Find Kth Largest XOR Coordinate Value coding problem gives you a 2D matrix. You define a new matrix value where value[i][j] is the XOR sum of all matrix[r][c] where and . You need to find the -th largest value in this derived value matrix.
Google uses this to test your proficiency with Bit Manipulation and 2D Prefix Sums. It evaluations whether you can apply the prefix sum pattern to XOR operations (which are their own inverse). It also tests your ability to find the -th largest element in a large set ( total values) using efficient selection algorithms like Quickselect or a Priority Queue.
The problem uses 2D Prefix XOR and Selection.
val[i][j] = matrix[i][j] ^ val[i-1][j] ^ val[i][j-1] ^ val[i-1][j-1].Matrix:
5 2
1 6
val[i-1][j-1] term back in (since it was included twice by the row and column XORs).XOR behaves mathematically exactly like addition in prefix sum formulas. If you know how to do a 2D prefix sum for additions, you know how to do it for XOR. The only difference is that , so the "subtraction" step is also just XOR.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Kth Largest Element in an Array | Medium | Solve | |
| Find the Kth Largest Integer in the Array | Medium | Solve | |
| Get Biggest Three Rhombus Sums in a Grid | Medium | Solve | |
| K Closest Points to Origin | Medium | Solve | |
| Average Height of Buildings in Each Segment | Medium | Solve |