|
| 1 | +<p>You are given a string <code>s</code> of lowercase English letters and an integer array <code>shifts</code> of the same length.</p> |
| 2 | + |
| 3 | +<p>Call the <code>shift()</code> of a letter, the next letter in the alphabet, (wrapping around so that <code>'z'</code> becomes <code>'a'</code>).</p> |
| 4 | + |
| 5 | +<ul> |
| 6 | + <li>For example, <code>shift('a') = 'b'</code>, <code>shift('t') = 'u'</code>, and <code>shift('z') = 'a'</code>.</li> |
| 7 | +</ul> |
| 8 | + |
| 9 | +<p>Now for each <code>shifts[i] = x</code>, we want to shift the first <code>i + 1</code> letters of <code>s</code>, <code>x</code> times.</p> |
| 10 | + |
| 11 | +<p>Return <em>the final string after all such shifts to s are applied</em>.</p> |
| 12 | + |
| 13 | +<p> </p> |
| 14 | +<p><strong class="example">Example 1:</strong></p> |
| 15 | + |
| 16 | +<pre> |
| 17 | +<strong>Input:</strong> s = "abc", shifts = [3,5,9] |
| 18 | +<strong>Output:</strong> "rpl" |
| 19 | +<strong>Explanation:</strong> We start with "abc". |
| 20 | +After shifting the first 1 letters of s by 3, we have "dbc". |
| 21 | +After shifting the first 2 letters of s by 5, we have "igc". |
| 22 | +After shifting the first 3 letters of s by 9, we have "rpl", the answer. |
| 23 | +</pre> |
| 24 | + |
| 25 | +<p><strong class="example">Example 2:</strong></p> |
| 26 | + |
| 27 | +<pre> |
| 28 | +<strong>Input:</strong> s = "aaa", shifts = [1,2,3] |
| 29 | +<strong>Output:</strong> "gfd" |
| 30 | +</pre> |
| 31 | + |
| 32 | +<p> </p> |
| 33 | +<p><strong>Constraints:</strong></p> |
| 34 | + |
| 35 | +<ul> |
| 36 | + <li><code>1 <= s.length <= 10<sup>5</sup></code></li> |
| 37 | + <li><code>s</code> consists of lowercase English letters.</li> |
| 38 | + <li><code>shifts.length == s.length</code></li> |
| 39 | + <li><code>0 <= shifts[i] <= 10<sup>9</sup></code></li> |
| 40 | +</ul> |
0 commit comments