You are not logged in. Please login at to post your questions!


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.



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



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

asked 28 Jul '14, 22:52

ravichandra22's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 28 Jul '14, 22:52

question was seen: 3,862 times

last updated: 28 Jul '14, 22:52