Imagine a magical string transformation system where each letter evolves through the alphabet! You are given a string s and an integer t representing the number of transformation rounds to perform.
In each transformation, every character follows these evolution rules:
- If the character is
'z', it splits into the string"ab" - Otherwise, it advances to the next character in the alphabet (
'a'→'b','b'→'c', etc.)
Your task is to determine the total length of the resulting string after exactly t transformations. Since the result can grow exponentially large, return the answer modulo 109 + 7.
Example: Starting with "az" and t=2:
Round 1: "az" → "bab" (a→b, z→ab)
Round 2: "bab" → "cbab" (b→c, a→b, b→c)
Final length: 4
Input & Output
Visualization
Time & Space Complexity
For each of t transformations, we update counts for 26 characters
Only need arrays of size 26 to store character counts
Constraints
- 1 ≤ s.length ≤ 105
- 1 ≤ t ≤ 104
- s consists only of lowercase English letters
- Answer must be returned modulo 109 + 7