Checking for each possible sub - matrix of size k X k
for ( var i = 0 ; i < N ; i ++ ) for ( var j = 0 ; j < N ; j ++ ) { var sum = getSum ( i , i + K , j , j + K , dp ) ; if ( sum == S ) return true ; }