Skip to content

Commit 5f8349c

Browse files
committed
1977. Number of Ways to Separate Numbers: RETRY
1 parent 6ad3157 commit 5f8349c

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

src/solution/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1490,3 +1490,4 @@ mod s1971_find_if_path_exists_in_graph;
14901490
mod s1974_minimum_time_to_type_word_using_special_typewriter;
14911491
mod s1975_maximum_matrix_sum;
14921492
mod s1976_number_of_ways_to_arrive_at_destination;
1493+
mod s1977_number_of_ways_to_separate_numbers;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
*/
34+
pub 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+
41+
impl Solution {
42+
pub fn number_of_combinations(num: String) -> i32 {
43+
0
44+
}
45+
}
46+
47+
// submission codes end
48+
49+
#[cfg(test)]
50+
mod tests {
51+
use super::*;
52+
53+
#[test]
54+
#[ignore]
55+
fn test_1977_example_1() {
56+
let num = "327".to_string();
57+
58+
let result = 2;
59+
60+
assert_eq!(Solution::number_of_combinations(num), result);
61+
}
62+
63+
#[test]
64+
#[ignore]
65+
fn test_1977_example_2() {
66+
let num = "094".to_string();
67+
68+
let result = 0;
69+
70+
assert_eq!(Solution::number_of_combinations(num), result);
71+
}
72+
73+
#[test]
74+
#[ignore]
75+
fn test_1977_example_3() {
76+
let num = "0".to_string();
77+
78+
let result = 0;
79+
80+
assert_eq!(Solution::number_of_combinations(num), result);
81+
}
82+
}

0 commit comments

Comments
 (0)