Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Pathetic Interview II

By spider004 · Limits 500ms, 512 MB

You all know about the story of Pathetic Interview-I. Today, I am sharing a story of my close friend who recently faced an online interview with “codecademy” which is an interactive platform that teaches people how to program. Surprisingly, instead of solving a particular problem he was asked to create a problem on Greedy Algorithm for the next contest and then upload it on his own GitHub account along with the exact solution to that problem.

He used the following git commands to upload the problem:

Git global setup
- git config –global “A_M”
- git config –global “”

Create a new repository
- git clone
- cd Pathetic_Interview-II
- touch
- git add
- git commit -m “Problem tag and solution is not guaranteed”
- git push -u origin master.

The file contains the following statement:
Zero and One are the most famous couple in the town. Once, Zero asked One whether she can form any number from herself with the help of operations like addition, multiplication, parenthesis-“( )” as many times as possible. One being confident of her math skills, said yes! Look how I form 10 = 1+1+1+1+1+1+1+1+1+1!!! It’s great and you are very talented! said Zero.
Now being a human your task is more difficult than that of One! You have to answer what is the minimum number of 1’s required to obtain the integer N? You can perform any operations like, Zero said to One earlier!


The input contains one and only integer N <= 30000.


The required number of ones.



Explanation of the sample case: (1 + 1 + 1) * (1 + 1) + 1 = 7.


61% Solution Ratio

rayhan50001Earliest, Jul '17

rathijitpaponFastest, 0.0s

rathijitpaponLightest, 131 kB

rathijitpaponShortest, 378B


Login to submit