RubrikOA #4
Two's Power (Regex)
Estimated EasyJudge-ready
Topics (AI-labelled)Strings
Determine whether the positive integer represented by a binary string is a power of 2. Leading zeros are allowed; zero itself is not a power of 2. The original problem asks for a regex match; this problem turns the locked match result into the standard output True/False.
Input
One line containing a non-empty binary string s (length 1..200000; a bound added by this site).
Output
Output True or False.
Example 1
Input:
1
Output:
True
Example 2
Input:
0001000
Output:
True
Example 3
Input:
101
Output:
False
Editorial
Loading solution…