Skip to content

Practice Number of Ways to Separate Numbers

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#1977
LeetCode Problem

Number of Ways to Separate Numbers

Problem Statement

You wrote down many positive integers in a string called num. However, you realized that you forgot to add commas to seperate the different numbers. You remember that the list of integers was non-decreasing and that no integer had leading zeros. Return the number of possible lists of integers that you could have written down to get the string num. Since the answer may be large, return it modulo 10^9 + 7.

Source: Number of Ways to Separate Numbers on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
num = "327"
Output
2

# Example 2

Input
num = "094"
Output
0

# Example 3

Input
num = "0"
Output
0

Constraints

1 <= num.length <= 3500
num consists of digits '0' through '9'.

Related LeetCode Problems

Practice more problems similar to Number of Ways to Separate Numbers.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.