3393. Count Paths With the Given XOR Value
You are given a 2D integer array
grid
with sizem x n
. You are also given an integerk
.Your task is to calculate the number of paths you can take from the top-left cell
(0, 0)
to the bottom-right cell(m - 1, n - 1)
satisfying the following constraints:
- You can either move to the right or down. Formally, from the cell
(i, j)
you may move to the cell(i, j + 1)
or to the cell(i + 1, j)
if the target cell exists.- The
XOR
of all the numbers on the path must be equal tok
.Return the total number of such paths.
Since the answer can be very large, return the result modulo
109 + 7
.
1 | class Solution { |