Class Solution
java.lang.Object
g2601_2700.s2645_minimum_additions_to_make_valid_string.Solution
2645 - Minimum Additions to Make Valid String.<p>Medium</p>
<p>Given a string <code>word</code> to which you can insert letters “a”, “b” or “c” anywhere and any number of times, return <em>the minimum number of letters that must be inserted so that <code>word</code> becomes <strong>valid</strong>.</em></p>
<p>A string is called <strong>valid</strong> if it can be formed by concatenating the string “abc” several times.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> word = “b”</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> Insert the letter “a” right before “b”, and the letter “c” right next to “a” to obtain the valid string “<strong>a</strong>b<strong>c</strong>”.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> word = “aaa”</p>
<p><strong>Output:</strong> 6</p>
<p><strong>Explanation:</strong> Insert letters “b” and “c” next to each “a” to obtain the valid string “a<strong>bc</strong>a<strong>bc</strong>a<strong>bc</strong>”.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> word = “abc”</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Explanation:</strong> word is already valid. No modifications are needed.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= word.length <= 50</code></li>
<li><code>word</code> consists of letters “a”, “b” and “c” only.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
addMinimum
-