Class Solution
-
- All Implemented Interfaces:
public final class Solution3335 - Total Characters in String After Transformations I.
Medium
You are given a string
sand an integert, representing the number of transformations to perform. In one transformation , every character insis 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
ttransformations.Since the answer may be very large, return it modulo <code>10<sup>9</sup> + 7</code>.
Example 1:
Input: s = "abcyy", t = 2
Output: 7
Explanation:
First Transformation (t = 1):
Second Transformation (t = 2):
Final Length of the string: The string is
"cdeabab", which has 7 characters.
Example 2:
Input: s = "azbk", t = 1
Output: 5
Explanation:
First Transformation (t = 1):
Final Length of the string: The string is
"babcl", which has 5 characters.
Constraints:
<code>1 <= s.length <= 10<sup>5</sup></code>
sconsists only of lowercase English letters.<code>1 <= t <= 10<sup>5</sup></code>
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntegerlengthAfterTransformations(String s, Integer t)-
-
Method Detail
-
lengthAfterTransformations
final Integer lengthAfterTransformations(String s, Integer t)
-
-
-
-