Class Solution
java.lang.Object
g2001_2100.s2063_vowels_of_all_substrings.Solution
2063 - Vowels of All Substrings.<p>Medium</p>
<p>Given a string <code>word</code>, return <em>the <strong>sum of the number of vowels</strong> (</em><code>'a'</code>, <code>'e'</code><em>,</em> <code>'i'</code><em>,</em> <code>'o'</code><em>, and</em> <code>'u'</code><em>)</em> <em>in every substring of</em> <code>word</code>.</p>
<p>A <strong>substring</strong> is a contiguous (non-empty) sequence of characters within a string.</p>
<p><strong>Note:</strong> Due to the large constraints, the answer may not fit in a signed 32-bit integer. Please be careful during the calculations.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> word = “aba”</p>
<p><strong>Output:</strong> 6</p>
<p><strong>Explanation:</strong> All possible substrings are: “a”, “ab”, “aba”, “b”, “ba”, and “a”.</p>
<ul>
<li>
<p>“b” has 0 vowels in it</p>
</li>
<li>
<p>“a”, “ab”, “ba”, and “a” have 1 vowel each</p>
</li>
<li>
<p>“aba” has 2 vowels in it</p>
</li>
</ul>
<p>Hence, the total sum of vowels = 0 + 1 + 1 + 1 + 1 + 2 = 6.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> word = “abc”</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> All possible substrings are: “a”, “ab”, “abc”, “b”, “bc”, and “c”.</p>
<ul>
<li>
<p>“a”, “ab”, and “abc” have 1 vowel each</p>
</li>
<li>
<p>“b”, “bc”, and “c” have 0 vowels each</p>
</li>
</ul>
<p>Hence, the total sum of vowels = 1 + 1 + 1 + 0 + 0 + 0 = 3.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> word = “ltcd”</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Explanation:</strong> There are no vowels in any substring of “ltcd”.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= word.length <= 10<sup>5</sup></code></li>
<li><code>word</code> consists of lowercase English letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
countVowels
-