Calculate String Transformations Length
For a string word of length n consisting of lowercase English characters, it can be transformed as follows.
1. If the character is 'z', it is replaced by "ab".
2. Otherwise, it is replaced by its next higher character, for example, 'a' is replaced by 'b', 'b' by 'c' ... and 'y' by 'z'.
Thus, if the initial string is "azbk" it is "babcl" after 1 transformation.
As a fun trivia, HackerRank publishes a puzzle for all its employees each week. The goal for this week is to find the length of the resultant string after exactly t transformations are performed as described above. Since the answer can be large, find the answer taking modulo (109 + 7).
1Example 1
Consider word = "abczy" and the number of transformations t = 2.
In the 1st transformation, the characters are transformed as follows:
- a → b
- b → c
- c → d
- z → ab
- y → z
In the 2nd transformation:
- b → c
- c → d
- d → e
- a → b
- b → c