Deci-Binary Partitioning Problem Solution

Partitioning into minimum number of deci-binary numbers Deci-binary means a number that contains only 0s and 1s, and no leading zeroes. Thought process: 🤔 After looking at the sample inputs, I realized that for an n-digit number, we need at least as many deci-binary numbers as the highest digit present in it. For example, if the number is 25, the possible deci-binary options we can subtract are 11 or 10. We keep subtracting valid deci-binary numbers from the given number until it becomes zero, and at the same time, we increment the count ➕. Once the number becomes zero, we simply return the count ✅. #leetcode #problem_solving #programming #binary #potd #consistency

  • text

More Simpler approach . let's suppose you are starting from zero to make the number n since we only use deci numbers i.e. all the numbers that contains 0 and 1 in its representation . we just need to find the max number present in the string and it always take max number of operations to reach there . for ex -: n = 463 and the digits in the number are {4,6,3} .now the max digit in the n is 6 so we always require exactly 6 operns i.e. 111 +111+ 111 + 110 + 010 + 010

Notes banane ke liye what do u use....??? Cause things looks similar to eraser..

Another code- *max_element(n.begin(), n.end()) - '0';

See more comments

To view or add a comment, sign in

Explore content categories