Skip to content

Practice Total Characters in String After Transformations II

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#3337
LeetCode Problem

Total Characters in String After Transformations II

Problem Statement

Given a lowercase string s, t, and a 26-entry array nums, transform every character simultaneously in each round. A letter at alphabet index j is replaced by the next nums[j] letters in cyclic alphabetical order, excluding the starting letter unless reached again by wrapping. For example, y with nums[24] = 3 becomes zab. Return the string length after exactly t rounds, modulo 10^9 + 7.

Source: Total Characters in String After Transformations II on LeetCode. Use the original task for its coding environment and submissions.

Examples

# 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
7

# 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
8

Constraints

1 <= s.length <= 10^5
s consists only of lowercase English letters.
1 <= t <= 10^9
nums.length == 26
1 <= nums[i] <= 25

Related LeetCode Problems

Practice more problems similar to Total Characters in String After Transformations II.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.