![]() |
VOOZH | about |
The problem is to check whether the decimal representation of the given binary number is divisible by 20 or not. Take care, the number could be very large and may not fit even in long long int. The approach should be such that there are zero or the minimum numbers of multiplication and division operations. No leadings 0’s are there in the input.
Examples:
Input : 101000 Output : Yes (10100)2 = (40)10 and 40 is divisible by 20.
Input : 110001110011100 Output : Yes
Approach:
Once we have the decimal representation of the binary number, we can check whether it is divisible by 20 by using the modulo operator (%). If the decimal representation is divisible by 20, then the binary number is also divisible by 20.
Implementation:
Yes
Output: Yes
Time Complexity: O(N)
Space Complexity: O(1)
Approach: Following are the steps:
Yes
Time Complexity: O(n), where n is the number of digits in the binary number.
Auxiliary Space: O(1)