Skip to content

Instantly share code, notes, and snippets.

@hinupurthakur
Created August 28, 2021 07:45
Show Gist options
  • Save hinupurthakur/bdecd7f75bc3f5d40bb82e8bee7cea5e to your computer and use it in GitHub Desktop.
Save hinupurthakur/bdecd7f75bc3f5d40bb82e8bee7cea5e to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
long long solve (string S) {
// Write your code here
long long mod=1000000007; //10^9+7 to prevent integer overflow
S = " "+S;
int freq[30]={0};
for(int i=1;i<S.size();i++){
freq[S[i]-'a']++;
}
long long ans=1;
for(int i=0;i<26;i++){
if(freq[i]){
ans*=freq[i];
ans%=mod;
}
}
return ans;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int T;
cin >> T;
for(int t_i=0; t_i<T; t_i++)
{
string S;
cin>>S;
long long out_;
out_ = solve(S);
cout << out_;
cout << "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment