Practice Count Paths With the Given XOR 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#3393
LeetCode ProblemCount Paths With the Given XOR Value
Problem Statement
Given grid and k, count paths from its top-left cell to its bottom-right cell that move only right or down and whose visited cell values have bitwise XOR equal to k. Include both endpoint values in the XOR. Return the count modulo 10^9 + 7.
Source: Count Paths With the Given XOR Value on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
grid = [[2, 1, 5], [7, 10, 0], [12, 6, 4]], k = 11
Output
3
# Example 2
Input
grid = [[1, 3, 3, 3], [0, 3, 3, 2], [3, 0, 1, 1]], k = 2
Output
5
# Example 3
Input
grid = [[1, 1, 1, 2], [3, 0, 3, 2], [3, 0, 2, 2]], k = 10
Output
0
Constraints
1 <= m == grid.length <= 300
1 <= n == grid[r].length <= 300
0 <= grid[r][c] < 16
0 <= k < 16
Related LeetCode Problems
Practice more problems similar to Count Paths With the Given XOR Value.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.