# [Leet Code] Number of Different Integers in a String

`Input: word = "a123bc34d8ef34"Output: 3Explanation: The three different integers are "123", "34", and "8". Notice that "34" is only counted once.`
`Input: word = "leet1234code234"Output: 2`
`Input: word = "a1b01c001"Output: 1Explanation: The three integers "1", "01", and "001" all represent the same integer becausethe leading zeros are ignored when comparing their decimal values.`
`class Solution(object):    def numDifferentIntegers(self, word):        """        :type word: str        :rtype: int        """        answers = []        lengthOfWord = len(word)        i = 0        while i < lengthOfWord:            if word[i].isnumeric():                number = ""                while i < lengthOfWord and word[i].isnumeric():                    number += word[i]                    i += 1                answers.append(int(number))            else:                i += 1        return len(set(answers))`

--

--

--

Learning, and posting my findings!

Love podcasts or audiobooks? Learn on the go with our new app.

## Matthew Boyd

Learning, and posting my findings!