Class Solution
java.lang.Object
g1801_1900.s1805_number_of_different_integers_in_a_string.Solution
1805 - Number of Different Integers in a String.<p>Easy</p>
<p>You are given a string <code>word</code> that consists of digits and lowercase English letters.</p>
<p>You will replace every non-digit character with a space. For example, <code>"a123bc34d8ef34"</code> will become <code>" 123 34 8 34"</code>. Notice that you are left with some integers that are separated by at least one space: <code>"123"</code>, <code>"34"</code>, <code>"8"</code>, and <code>"34"</code>.</p>
<p>Return <em>the number of <strong>different</strong> integers after performing the replacement operations on</em> <code>word</code>.</p>
<p>Two integers are considered different if their decimal representations <strong>without any leading zeros</strong> are different.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> word = “a123bc34d8ef34”</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> The three different integers are “123”, “34”, and “8”. Notice that “34” is only counted once.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> word = “leet1234code234”</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> word = “a1b01c001”</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Explanation:</strong> The three integers “1”, “01”, and “001” all represent the same integer because the leading zeros are ignored when comparing their decimal values.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= word.length <= 1000</code></li>
<li><code>word</code> consists of digits and lowercase English letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
numDifferentIntegers
-