Set current state to visited
v [ i , j , m ] = true ; dp [ i , j , m ] = findCount ( mat , i - 1 , j , m - mat [ i , j ] ) + findCount ( mat , i , j - 1 , m - mat [ i , j ] ) ; return dp [ i , j , m ] ; }