1977. Number of Ways to Separate Numbers Hard
1/**
2 * [1977] Number of Ways to Separate Numbers
3 *
4 * 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.
5 * 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.
6 *
7 * Example 1:
8 *
9 * Input: num = "327"
10 * Output: 2
11 * Explanation: You could have written down the numbers:
12 * 3, 27
13 * 327
14 *
15 * Example 2:
16 *
17 * Input: num = "094"
18 * Output: 0
19 * Explanation: No numbers can have leading zeros and all numbers must be positive.
20 *
21 * Example 3:
22 *
23 * Input: num = "0"
24 * Output: 0
25 * Explanation: No numbers can have leading zeros and all numbers must be positive.
26 *
27 *
28 * Constraints:
29 *
30 * 1 <= num.length <= 3500
31 * num consists of digits '0' through '9'.
32 *
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/number-of-ways-to-separate-numbers/
37// discuss: https://leetcode.com/problems/number-of-ways-to-separate-numbers/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42 pub fn number_of_combinations(num: String) -> i32 {
43 0
44 }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 #[test]
54 fn test_1977() {
55 }
56}
57
Back
© 2025 bowen.ge All Rights Reserved.