You are not logged in. Please login at www.codechef.com 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.

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).

asked 28 Jul '14, 22:52

ravichandra22's gravatar image

0★ravichandra22
1111
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×1,916
×1,490
×1,313
×365
×118
×92

question asked: 28 Jul '14, 22:52

question was seen: 3,862 times

last updated: 28 Jul '14, 22:52