Check if it is possible to move from ( 0 , 0 ) to ( X , Y ) in exactly K steps | Java implementation of the approach ; Function that returns true if it is possible to move from ( 0 , 0 ) to ( x , y ) in exactly k moves ; Minimum moves required ; If possible ; Driver code
class GFG { static boolean isPossible ( int x , int y , int k ) { int minMoves = Math . abs ( x ) + Math . abs ( y ) ; if ( k >= minMoves && ( k - minMoves ) % 2 == 0 ) return true ; return false ; } public static void main ( String [ ] args ) { int x = 5 , y = 8 , k = 20 ; if ( isPossible ( x , y , k ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }