I have a nxn matrix,which contains some numbers as values in the grid and some grid contains the block.I have to find the number of path from the source to destination which adds upto given sum k

input:

s 1 1

1 x 1

1 1 d

k = 3

output : 2

There are only two paths possible from source to destination for a given sum.

Implement using Dynamic programming either in c/c++