1738. Find Kth Largest XOR Coordinate Value Medium

@problem@discussion
#Array#Divide and Conquer#Bit Manipulation#Heap (Priority Queue)#Matrix#Prefix Sum#Quickselect



1/**
2 * [1738] Find Kth Largest XOR Coordinate Value
3 *
4 * You are given a 2D matrix of size m x n, consisting of non-negative integers. You are also given an integer k.
5 * The value of coordinate (a, b) of the matrix is the XOR of all matrix[i][j] where 0 <= i <= a < m and 0 <= j <= b < n (0-indexed).
6 * Find the k^th largest value (1-indexed) of all the coordinates of matrix.
7 *  
8 * Example 1:
9 * 
10 * Input: matrix = [[5,2],[1,6]], k = 1
11 * Output: 7
12 * Explanation: The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value.
13 * 
14 * Example 2:
15 * 
16 * Input: matrix = [[5,2],[1,6]], k = 2
17 * Output: 5
18 * Explanation: The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value.
19 * 
20 * Example 3:
21 * 
22 * Input: matrix = [[5,2],[1,6]], k = 3
23 * Output: 4
24 * Explanation: The value of coordinate (1,0) is 5 XOR 1 = 4, which is the 3rd largest value.
25 *  
26 * Constraints:
27 * 
28 * 	m == matrix.length
29 * 	n == matrix[i].length
30 * 	1 <= m, n <= 1000
31 * 	0 <= matrix[i][j] <= 10^6
32 * 	1 <= k <= m * n
33 * 
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/find-kth-largest-xor-coordinate-value/
38// discuss: https://leetcode.com/problems/find-kth-largest-xor-coordinate-value/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43    pub fn kth_largest_value(matrix: Vec<Vec<i32>>, k: i32) -> i32 {
44        0
45    }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52    use super::*;
53
54    #[test]
55    fn test_1738() {
56    }
57}
58


Back
© 2025 bowen.ge All Rights Reserved.