dp [ a , b ] , here a , b is the difference of x & tx and y & ty respectively .
dp [ 1 , 0 ] = 3 ; dp [ 0 , 1 ] = 3 ; dp [ 1 , 1 ] = 2 ; dp [ 2 , 0 ] = 2 ; dp [ 0 , 2 ] = 2 ; dp [ 2 , 1 ] = 1 ; dp [ 1 , 2 ] = 1 ; ans = getsteps ( x , y , tx , ty ) ; } Console . WriteLine ( ans ) ; } }