Skip to content

Practice Find Kth Largest XOR Coordinate Value

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1738
LeetCode Problem

Find Kth Largest XOR Coordinate Value

Problem Statement

You are given a 2D matrix of size m x n, consisting of non-negative integers. You are also given an integer k. 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). Find the kth largest value (1-indexed) of all the coordinates of matrix.

Source: Find Kth Largest XOR Coordinate Value on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
matrix = [[5,2],[1,6]], k = 1
Output
7

# Example 2

Input
matrix = [[5,2],[1,6]], k = 2
Output
5

# Example 3

Input
matrix = [[5,2],[1,6]], k = 3
Output
4

Constraints

m == matrix.length
n == matrix[i].length
1 <= m, n <= 1000
0 <= matrix[i][j] <= 10^6
1 <= k <= m * n

Related LeetCode Problems

Practice more problems similar to Find Kth Largest XOR Coordinate Value.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.