Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
The actual numbers in grid do not matter. What matters are the remainders you get when you divide the numbers by k.
We can use dynamic programming to solve this problem. What can we use as states?
Let dp[i][j][value] represent the number of paths where the sum of the elements on the path has a remainder of value when divided by k.