Total Characters in String After Transformations II
You are given a string s consisting of lowercase English letters, an integer t representing the number of transformations to perform, and an array nums of size 26.
In one transformation, every character in s is replaced according to the following rules:
- Replace
s[i]with the nextnums[s[i] - 'a']consecutive characters in the alphabet. - The transformation wraps around the alphabet if it exceeds
'z'.
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
Input
s = "abcyy", t = 2, nums = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2]Output
7After two transformations, the string becomes
"cdeabab", which has 7 characters.Example 2
Input
s = "azbk", t = 1, nums = [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]Output
8After one transformation, the string becomes
"bcabcdlm", which has 8 characters.Constraints
- 1 <= s.length <= 10^5
- s consists only of lowercase English letters.
- 1 <= t <= 10^9
- nums.length == 26
- 1 <= nums[i] <= 25