A TikTok user has a username represented by a string of lowercase English letters, username. The user wants to transform their username to explore possible variations. The user can perform the following operations on the username multiple times, in any order:
The user may also choose not to apply any operations, leaving the username unchanged.
Given the string username, determine the total number of distinct usernames that can be generated by applying these transformations. Since the result can be large, return the total count modulo 109+7.
Examples
01 · Example 1
username = "ccc" return = 3
The possible usernames that can be generated are:
"ccc" → "ac"
"ccc" → "ca"
"ccc" (No operation is applied)
Hence the answer is 3.
More Tiktok problems
- Count Cyclic Digit PairsOA · Seen Jun 2026
- Count Skipped Numbers After SubtractionsOA · Seen Jun 2026
- Event ID Check Completion TimesOA · Seen Jun 2026
- Check Even-Position MonotonicityOA · Seen Jun 2026
- Count Alternating Tile GroupsOA · Seen Jun 2026
- Count Even-Digit NumbersOA · Seen Jun 2026
- Inventory Discount TrackerOA · Seen Jun 2026
- Construct WDL StringOA · Seen Jun 2026
public int distinctUsernames(String username) {
// write your code here
}
username"ccc"
expected3
checking account