My issue
Problem Link: VOWMTRX Problem - CodeChef
For this problem I had written the following code:
#include"bits/stdc++.h"
using namespace std;
int main() {
int t;
cin >> t;
while(t--){
int n, k;
cin >> n >> k;
long long int m = 1000000007;
string str;
cin >> str;
int curr_vowels = 0;
bool count_consonants = false;
int consonant_count = 0;
int number_of_groups = 0;
int total = 1;
for(int i=0; i<str.length(); i++){
if(str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u'){
count_consonants = false;
curr_vowels++;
}
else if(count_consonants){
consonant_count++;
}
if(curr_vowels == k){
number_of_groups++;
total *= (consonant_count+1);
count_consonants = true;
curr_vowels = 0;
consonant_count = 0;
}
}
if(number_of_groups == 0 || number_of_groups == 1){
cout << 0 << endl;
}
else{
cout << total%m << endl;
}
}
return 0;
}
Can someone explain to me why this code is not working with an example testcasel