java.lang.Object
g1901_2000.s1977_number_of_ways_to_separate_numbers.Solution

public class Solution extends Object
1977 - Number of Ways to Separate Numbers.<p>Hard</p> <p>You wrote down many <strong>positive</strong> integers in a string called <code>num</code>. However, you realized that you forgot to add commas to seperate the different numbers. You remember that the list of integers was <strong>non-decreasing</strong> and that <strong>no</strong> integer had leading zeros.</p> <p>Return <em>the <strong>number of possible lists of integers</strong> that you could have written down to get the string</em> <code>num</code>. Since the answer may be large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> num = &ldquo;327&rdquo;</p> <p><strong>Output:</strong> 2</p> <p><strong>Explanation:</strong> You could have written down the numbers: 3, 27 327</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> num = &ldquo;094&rdquo;</p> <p><strong>Output:</strong> 0</p> <p><strong>Explanation:</strong> No numbers can have leading zeros and all numbers must be positive.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> num = &ldquo;0&rdquo;</p> <p><strong>Output:</strong> 0</p> <p><strong>Explanation:</strong> No numbers can have leading zeros and all numbers must be positive.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= num.length <= 3500</code></li> <li><code>num</code> consists of digits <code>'0'</code> through <code>'9'</code>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • numberOfCombinations

      public int numberOfCombinations(String num)