1805. Number of Different Integers in a String
On This Page
class Solution:
def numDifferentIntegers(self, word: str) -> int:
s = set()
i, n = 0, len(word)
while i < n:
if word[i].isdigit():
while i < n and word[i] == '0':
i += 1
j = i
while j < n and word[j].isdigit():
j += 1
s.add(word[i:j])
i = j
i += 1
return len(s)