VOOZH about

URL: https://www.geeksforgeeks.org/dsa/divisibility-64-removal-bits-allowed/

⇱ Divisibility by 64 with removal of bits allowed - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Divisibility by 64 with removal of bits allowed

Last Updated : 21 Jun, 2022

Given a binary string, we need to check whether that number is divisible by 64 or not after removing of some bits. If yes then print "possible" else "not possible". We cannot make number 0 to make it divisible.
Example : 
 

Input: 100010001 
Output: Possible
Explanation: We can get string 1 000 000 
after removing two ones which is a 
representation of number 64 in the binary 
numerical system.

Input: 100
Output: Not possible
Explanation : The number is 4 which is not 
divisible by 64 or cannot be made possible 
my removing some digits.


 


If we have 6 zeros after any one, then we can remove other bits represent it as a multiple of 64. So we just need to check if there is a 1 before six zeros. 
 

Output : 
 

Possible


Time Complexity: O(length of string)

Space Complexity: O(1)
 


 

Comment