Binary Decimal ( Zoho Round 2 Question )

0

0 votes
Medium
Problem

A number is called as binary-decimal if all the digits in the number should be either ‘1’ or ‘0’. Any number can be written as a sum of binary-decimals. Our task is to find the minimum number of binary-decimals to represent a number.

.Input : 32

Output : 11+11+10=32

Explanation : 11+11+10=32. In each, only 1 or 0 is present. (count = 3)

Another possible solution:

10+10+10+1+1=32.

Here the count of the values is 5. But we need the optimized count of the values.

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?