Skip to content

Practice Number of Different Integers in a String

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1805
LeetCode Problem

Number of Different Integers in a String

Problem Statement

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  34 8  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.

Source: Number of Different Integers in a String on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
word = "a123bc34d8ef34"
Output
3

# Example 2

Input
word = "leet1234code234"
Output
2

# Example 3

Input
word = "a1b01c001"
Output
1

Constraints

1 <= word.length <= 1000
word consists of digits and lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Number of Different Integers in a String.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.