Interview Written test problem

optimal number of cut to get number in powers of 5

Interview Written test problem

You have to complete a function int optimalCuts(string s),where s is a string contains 0’s and 1’s.It has to return
smallest +ve integer C,Such that,the bit string cab be cut into pieces and each piece is a power of 5.Note the piece
can also represent different power of 5.if no cut is possible then return -1.

Constrains
String s consists of only 1’s and 0’s.
1<=length(s)<=50.

Sample#1
s=101101101

Return 3

Explanation:We can Split String into three "101"s,where 101 is binary 5.

Sample#2

s=1111101

Return 1(“1111101” is 125 which is 5^3).

Sample#3

s=00000

Return -1(0 is not power of 5).