Check if it is possible to reach ( x , y ) from origin in exactly Z steps using only plus movements | Java program for the above approach ; Function to check if it is possible to reach ( x , y ) from origin in exactly z steps ; Condition if we can 't reach in Z steps ; Driver Code ; Destination point coordinate ; Number of steps allowed ; Function Call
class GFG { static void possibleToReach ( int x , int y , int z ) { if ( z < Math . abs ( x ) + Math . abs ( y ) || ( z - Math . abs ( x ) - Math . abs ( y ) ) % 2 == 1 ) { System . out . print ( " Not ▁ Possible " + "NEW_LINE"); } else System . out . print ( " Possible " + "NEW_LINE"); } public static void main ( String [ ] args ) { int x = 5 , y = 5 ; int z = 11 ; possibleToReach ( x , y , z ) ; } }