Divisibility by 64 with removal of bits allowed | Java program to find if given binary string can become divisible by 64 after removing some bits ; function to check if it is possible to make it a multiple of 64. ; counter to count 0 's ; length of the string ; loop which traverses right to left and calculates the number of zeros before 1. ; Driver code
import java . io . * ; class GFG { static boolean checking ( String s ) { int c = 0 ; int n = s . length ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == '0' ) c ++ ; if ( c >= 6 && s . charAt ( i ) == '1' ) return true ; } return false ; } public static void main ( String [ ] args ) { String s = "100010001" ; if ( checking ( s ) ) System . out . println ( " Possible " ) ; else System . out . println ( " Not ▁ possible " ) ; } }