Is it possible to reach N and M from 1 and 0 respectively as per given condition | Java program for the above approach ; Function that find given x and y is possible or not ; Check if x is less than 2 and y is not equal to 0 ; Perform subtraction ; Check if y is divisible by 2 and greater than equal to 0 ; Driver Code ; Given X and Y ; Function Call
class GFG { static boolean is_possible ( int x , int y ) { if ( x < 2 && y != 0 ) return false ; y = y - x + 1 ; if ( y % 2 == 0 && y >= 0 ) return true ; else return false ; } public static void main ( String [ ] args ) { int x = 5 , y = 2 ; if ( is_possible ( x , y ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }