|
| 1 | +<p>Alice is attempting to type a specific string on her computer. However, she tends to be clumsy and <strong>may</strong> press a key for too long, resulting in a character being typed <strong>multiple</strong> times.</p> |
| 2 | + |
| 3 | +<p>You are given a string <code>word</code>, which represents the <strong>final</strong> output displayed on Alice's screen. You are also given a <strong>positive</strong> integer <code>k</code>.</p> |
| 4 | + |
| 5 | +<p>Return the total number of <em>possible</em> original strings that Alice <em>might</em> have intended to type, if she was trying to type a string of size <strong>at least</strong> <code>k</code>.</p> |
| 6 | + |
| 7 | +<p>Since the answer may be very large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p> |
| 8 | + |
| 9 | +<p> </p> |
| 10 | +<p><strong class="example">Example 1:</strong></p> |
| 11 | + |
| 12 | +<div class="example-block"> |
| 13 | +<p><strong>Input:</strong> <span class="example-io">word = "aabbccdd", k = 7</span></p> |
| 14 | + |
| 15 | +<p><strong>Output:</strong> <span class="example-io">5</span></p> |
| 16 | + |
| 17 | +<p><strong>Explanation:</strong></p> |
| 18 | + |
| 19 | +<p>The possible strings are: <code>"aabbccdd"</code>, <code>"aabbccd"</code>, <code>"aabbcdd"</code>, <code>"aabccdd"</code>, and <code>"abbccdd"</code>.</p> |
| 20 | +</div> |
| 21 | + |
| 22 | +<p><strong class="example">Example 2:</strong></p> |
| 23 | + |
| 24 | +<div class="example-block"> |
| 25 | +<p><strong>Input:</strong> <span class="example-io">word = "aabbccdd", k = 8</span></p> |
| 26 | + |
| 27 | +<p><strong>Output:</strong> <span class="example-io">1</span></p> |
| 28 | + |
| 29 | +<p><strong>Explanation:</strong></p> |
| 30 | + |
| 31 | +<p>The only possible string is <code>"aabbccdd"</code>.</p> |
| 32 | +</div> |
| 33 | + |
| 34 | +<p><strong class="example">Example 3:</strong></p> |
| 35 | + |
| 36 | +<div class="example-block"> |
| 37 | +<p><strong>Input:</strong> <span class="example-io">word = "aaabbb", k = 3</span></p> |
| 38 | + |
| 39 | +<p><strong>Output:</strong> <span class="example-io">8</span></p> |
| 40 | +</div> |
| 41 | + |
| 42 | +<p> </p> |
| 43 | +<p><strong>Constraints:</strong></p> |
| 44 | + |
| 45 | +<ul> |
| 46 | + <li><code>1 <= word.length <= 5 * 10<sup>5</sup></code></li> |
| 47 | + <li><code>word</code> consists only of lowercase English letters.</li> |
| 48 | + <li><code>1 <= k <= 2000</code></li> |
| 49 | +</ul> |
0 commit comments