Distinct subsequence

i have pass only one test case out of 5,i am getting wrong answer,and i also solved by dp

please provide ur code paste the code in CB ide

@Einsteve7974
try this out


in case problem still persists give me link of the question on hack.codingblocks

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
int main() {
int t;
cin>>t;
while(t–)
{
string str;
cin>>str;
ll n=str.length();
ll dp[n+1];
int prev[26];
memset(prev,-1,sizeof(prev));
dp[0]=1;
for(int i=1;i<=n;i++)
{
dp[i]=((2%mod)*(dp[i-1]%mod))%mod;

	 if(prev[str[i-1]-'A']!=-1)
	 {
	   dp[i]=(dp[i]%mod-dp[prev[str[i-1]-'A']]%mod)%mod;
	}
	 prev[str[i-1]-'A']=(i-1);
}

cout<<dp[n]%mod<<"\n";
}
}

Does this code work now? or u require furthur assistance?