Modify a binary array to Bitwise AND of all elements as 1 | Java implementation of the above approach ; Function to check if it is possible or not ; Driver code
class GFG { static boolean check ( int a [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) if ( a [ i ] == 1 ) return true ; return false ; } public static void main ( String [ ] args ) { int a [ ] = { 0 , 1 , 0 , 1 } ; int n = a . length ; if ( check ( a , n ) == true ) System . out . println ( "YESNEW_LINE") ; else System . out . println ( "NONEW_LINE"); } }