java.lang.Object
g1601_1700.s1689_partitioning_into_minimum_number_of_deci_binary_numbers.Solution

public class Solution extends Object
1689 - Partitioning Into Minimum Number Of Deci-Binary Numbers.<p>Medium</p> <p>A decimal number is called <strong>deci-binary</strong> if each of its digits is either <code>0</code> or <code>1</code> without any leading zeros. For example, <code>101</code> and <code>1100</code> are <strong>deci-binary</strong> , while <code>112</code> and <code>3001</code> are not.</p> <p>Given a string <code>n</code> that represents a positive decimal integer, return <em>the <strong>minimum</strong> number of positive <strong>deci-binary</strong> numbers needed so that they sum up to</em> <code>n</code><em>.</em></p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> n = &ldquo;32&rdquo;</p> <p><strong>Output:</strong> 3</p> <p><strong>Explanation:</strong> 10 + 11 + 11 = 32</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> n = &ldquo;82734&rdquo;</p> <p><strong>Output:</strong> 8</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> n = &ldquo;27346209830709182346&rdquo;</p> <p><strong>Output:</strong> 9</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= n.length <= 10<sup>5</sup></code></li> <li><code>n</code> consists of only digits.</li> <li><code>n</code> does not contain any leading zeros and represents a positive integer.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • minPartitions

      public int minPartitions(String n)