1805. Number of Different Integers in a String Easy
1/**
2 * [1805] Number of Different Integers in a String
3 *
4 * You are given a string word that consists of digits and lowercase English letters.
5 * You will replace every non-digit character with a space. For example, "a123bc34d8ef34" will become " 123 34 8 34". Notice that you are left with some integers that are separated by at least one space: "123", "34", "8", and "34".
6 * Return the number of different integers after performing the replacement operations on word.
7 * Two integers are considered different if their decimal representations without any leading zeros are different.
8 *
9 * Example 1:
10 *
11 * Input: word = "a<u>123</u>bc<u>34</u>d<u>8</u>ef<u>34</u>"
12 * Output: 3
13 * Explanation: The three different integers are "123", "34", and "8". Notice that "34" is only counted once.
14 *
15 * Example 2:
16 *
17 * Input: word = "leet<u>1234</u>code<u>234</u>"
18 * Output: 2
19 *
20 * Example 3:
21 *
22 * Input: word = "a<u>1</u>b<u>01</u>c<u>001</u>"
23 * Output: 1
24 * Explanation: The three integers "1", "01", and "001" all represent the same integer because
25 * the leading zeros are ignored when comparing their decimal values.
26 *
27 *
28 * Constraints:
29 *
30 * 1 <= word.length <= 1000
31 * word consists of digits and lowercase English letters.
32 *
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/number-of-different-integers-in-a-string/
37// discuss: https://leetcode.com/problems/number-of-different-integers-in-a-string/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42 pub fn num_different_integers(word: 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_1805() {
55 }
56}
57
Back
© 2025 bowen.ge All Rights Reserved.