Find the last remaining element after repeated removal of an element from pairs of increasing adjacent array elements | Java program for the above approach ; Function to print the last remaining array element after after performing given operations ; If size of the array is 1 ; Check for the condition ; If condition is not satisfied ; Driver Code ; Function Call
import java . io . * ; class GFG { static void canArrayBeReduced ( int [ ] arr , int N ) { if ( N == 1 ) { System . out . print ( arr [ 0 ] ) ; return ; } if ( arr [ 0 ] < arr [ N - 1 ] ) { System . out . print ( arr [ N - 1 ] ) ; } else System . out . print ( " Not ▁ Possible " ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 6 , 5 , 2 , 4 , 1 , 3 , 7 } ; int N = arr . length ; canArrayBeReduced ( arr , N ) ; } }