java.lang.Object
g1701_1800.s1738_find_kth_largest_xor_coordinate_value.Solution

public class Solution extends Object
1738 - Find Kth Largest XOR Coordinate Value.<p>Medium</p> <p>You are given a 2D <code>matrix</code> of size <code>m x n</code>, consisting of non-negative integers. You are also given an integer <code>k</code>.</p> <p>The <strong>value</strong> of coordinate <code>(a, b)</code> of the matrix is the XOR of all <code>matrix[i][j]</code> where <code>0 <= i <= a < m</code> and <code>0 <= j <= b < n</code> <strong>(0-indexed)</strong>.</p> <p>Find the <code>k<sup>th</sup></code> largest value <strong>(1-indexed)</strong> of all the coordinates of <code>matrix</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> matrix = [[5,2],[1,6]], k = 1</p> <p><strong>Output:</strong> 7</p> <p><strong>Explanation:</strong> The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> matrix = [[5,2],[1,6]], k = 2</p> <p><strong>Output:</strong> 5</p> <p><strong>Explanation:</strong> The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> matrix = [[5,2],[1,6]], k = 3</p> <p><strong>Output:</strong> 4</p> <p><strong>Explanation:</strong> The value of coordinate (1,0) is 5 XOR 1 = 4, which is the 3rd largest value.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>m == matrix.length</code></li> <li><code>n == matrix[i].length</code></li> <li><code>1 <= m, n <= 1000</code></li> <li><code>0 <= matrix[i][j] <= 10<sup>6</sup></code></li> <li><code>1 <= k <= m * n</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • kthLargestValue

      public int kthLargestValue(int[][] matrix, int k)