Leaderboard
Showing:
Handle Score
@Ibrahim Nash 5725
@blackshadows 5685
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Complete Leaderboard
Cutting Binary String
Easy Accuracy: 25.3% Submissions: 5071 Points: 2

Given a string s containing 0's and 1's. You have to return a smallest positive integer C, such that the binary string can be cut into C pieces and each piece should be of the power of 5  with no leading zeros.

Input:
The first line of the input contains denoting the number of test cases. For each test case, there is a string s.

Output:
For each test case, the output is an integer C. If no such cuts are possible then return -1. 

Constraints:
1<=s.length()<=50
Note: The string is a binary string.

Example:
Input

3
101101101
1111101
00000
Output:
3
1
-1

Explanation:
1.
We can split the given string into three “101”s, where 101 is the binary representation of 5.
2."1111101 " is 125 which is 5^3.
3.0 is not a power of 5.

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Cutting Binary String

Output Window