Total Characters in String After Transformations I

You are given a string s and an integer t, representing the number of transformations to perform. In one transformation, every character in s is replaced according to the following rules:

  • If the character is 'z', replace it with the string "ab".
  • Otherwise, replace it with the next character in the alphabet. For example, 'a' is replaced with 'b', 'b' is replaced with 'c', and so on.

Return the length of the resulting string after exactly t transformations.

Since the answer may be very large, return it modulo 10^9 + 7.

Example 1
Inputs = "abcyy", t = 2
Output7
After two transformations, "abcyy" becomes "cdeabab", which has 7 characters.
Example 2
Inputs = "azbk", t = 1
Output5
After one transformation, "azbk" becomes "babcl", which has 5 characters.

Constraints

  • 1 <= s.length <= 10^5
  • s consists only of lowercase English letters.
  • 1 <= t <= 10^5

Asked at 4 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate