Skip to content

Commit 2f19517

Browse files
authored
Create 3335. Total Characters in String After Transformations I (#793)
2 parents 7fba8f7 + 99c1628 commit 2f19517

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class Solution {
2+
public:
3+
int mod=1e9+7;
4+
int lengthAfterTransformations(string s, int t) {
5+
vector<long long>cnt(26,0);
6+
for(char ch:s)cnt[ch-'a']++;
7+
while(t--){
8+
vector<long long>updated(26,0);
9+
for(int i=0;i<26;i++){
10+
if(i==25){
11+
updated[0]=(updated[0]+cnt[i])%mod;
12+
updated[1]=(updated[1]+cnt[i])%mod;
13+
}
14+
else{
15+
updated[i+1]=(updated[i+1]+cnt[i])%mod;
16+
}
17+
}
18+
cnt=updated;
19+
}
20+
long long ans=0;
21+
for(auto c:cnt){
22+
ans=(ans+c)%mod;
23+
}
24+
return (int)ans;
25+
}
26+
};

0 commit comments

Comments
 (0)