#3335
Total Characters in String After Transformations I
specialist · 935 · lc medium +32 · 45.7% accepted · 612 likes · top 29%
Description
You are given a string s and an integer t representing how many transformations to apply. In each transformation, every character in s is replaced according to these rules:
- The character 'z' becomes the string "ab".
- Any other character advances to the next letter in the alphabet (e.g., 'a' becomes 'b', 'b' becomes '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 109 + 7.
Code
1
2
3