Finding difficulty in case of submitting the code of Count Subsequences

#include <bits/stdc++.h>
using namespace std;
const int MAX_CHAR=256;

int countSub(string str){
vector v(MAX_CHAR,-1);
int n=str.length();
int dp[n+1];
dp[0]=1;
for(int i=1;i<=n;i++){
dp[i]=(2*dp[i-1])%1000000007;
if(v[str[i-1]]!=-1){
dp[i]=(dp[i]-dp[v[str[i-1]]]+1000000007)%1000000007;
}
v[str[i-1]]=(i-1);
}
return dp[n]%1000000007;
}

int main() {

int t;
cin>>t;
while(t--){
    string str;
    cin>>str;
    cout<<countSub(str)<<endl;
}
return 0;

}

//this is not working

What’s the error you are facing? Or you are unable to submit? If so, drop a mail to [email protected] .

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.