My issue
can you give reason why my code is failed?
My code
//Radhe Radhe
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const int M = 1e9 + 7;
bool isVowel(char &x){
if(x =='a'|| x=='e'||x=='i'||x=='o'||x=='u')return true;
return false;
}
void Radhe(){
ll t;
cin>>t;
while(t--){
int n,k;
cin>>n>>k;
string s;
cin>>s;
vector<int>ans;
int j = 0;
for(int i=0;i<n;i++){
if(isVowel(s[i])){
j++;
}
if(j==k){
i++;
int curr = 0;
while(i<n && !isVowel(s[i])){
curr++;
i++;
}
if(i!=(n-1)){
// i--;
ans.push_back(curr+1);
}
j=0;
}
}
// for(auto x:ans)cout<<x<<" ";
// cout<<endl;
long long int res = 1;
for(auto x:ans){
res = ((res%M )*(x%M ))%M;
}
cout<<res<<endl;
}
}
int main(){
Radhe();
return 0;
}
Problem Link: The Vowel Matrix Practice Coding Problem - CodeChef