Check if it is possible to reach destination in even number of steps in an Infinite Matrix | Java program for the above approach ; Function to check destination can be reached from source in even number of steps ; Coordinates differences ; Minimum number of steps required ; Minsteps is even ; Minsteps is odd ; Driver code ; Given Input ; Function Call
import java . lang . * ; import java . util . * ; class GFG { static void IsEvenPath ( int Source [ ] , int Destination [ ] ) { int x_dif = Math . abs ( Source [ 0 ] - Destination [ 0 ] ) ; int y_dif = Math . abs ( Source [ 1 ] - Destination [ 1 ] ) ; int minsteps = x_dif + y_dif ; if ( minsteps % 2 == 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static void main ( String [ ] args ) { int Source [ ] = { 2 , 1 } ; int Destination [ ] = { 1 , 4 } ; IsEvenPath ( Source , Destination ) ; } }