You are given a string word that consists of digits and lowercase English letters.

You will replace every non-digit character with a space. For example, "a123bc34d8ef34" will become " 123&nbsp; 34 8&nbsp; 34". Notice that you are left with some integers that are separated by at least one space: "123", "34", "8", and "34".

Return the number of different integers after performing the replacement operations on word.

Two integers are considered different if their decimal representations without any leading zeros are different.

&nbsp;
Example 1:

Input: word = "a123bc34d8ef34"
Output: 3
Explanation: The three different integers are "123", "34", and "8". Notice that "34" is only counted once.


Example 2:

Input: word = "leet1234code234"
Output: 2


Example 3:

Input: word = "a1b01c001"
Output: 1
Explanation: The three integers "1", "01", and "001" all represent the same integer because
the leading zeros are ignored when comparing their decimal values.


&nbsp;
Constraints:


	1 &lt;= word.length &lt;= 1000
	word consists of digits and lowercase English letters.


class Solution:
    def numDifferentIntegers(self, word: str) -> int:

        word = re.findall('(\d+)', word)
        numbers = [int(i) for i in word]

        return len(set(numbers))
class Solution {
    public int numDifferentIntegers(String word) {
        String[] arr = word.replaceAll("[a-zA-Z]", " ").split("\\s+");
        Set<String> set = new HashSet<String>();

        for (String str : arr) {
            if (!str.isEmpty())
                set.add(String.valueOf(str.replaceAll("^0*","")));
        }

        return set.size();
    }
}
class Solution {
public:
    int numDifferentIntegers(string word) {
        unordered_map<string, int> hmap;
        for (int i = 0; i < word.size(); i++) {
            if (isdigit(word[i])) {
                string str;
                while (word[i] == '0')
                    i++;
                while (isdigit(word[i]))
                    str += word[i++];
                hmap[str]++;
            }
        }
        return hmap.size();
    }
};
const CC0 = '0'.charCodeAt(0);

var numDifferentIntegers = function(word) {
    const numStrSet = new Set();
    
    // get numbers as strings
    const numStrs = word.split(/[^0-9]+/);
    
    // drop leading zeros
    for (const numStr of numStrs) {
        if (numStr.length > 0) {
            let i = 0;
            while (numStr.charCodeAt(i) === CC0) i++;
            
            // make sure that we preserve last 0 if string is composed of zeros only
            numStrSet.add(numStr.slice(i) || '0');
        }
    }
    
    return numStrSet.size;
};
Number of Different Integers in a String