two test cases are failing and i know the reasons why…like
- it will give incoorect outp for the inp-aabc and many more like that.
but i am unable to crack the right code…i tried as much as i can
please help
#include
#include
using namespace std;
void countpall(char a[]){
int len=strlen(a);
int i=0;
int j=1;
int cnt=0;
while(j<len){
if(a[i]!=a[j]){
i++;
if(i==j){
j++;
}
}
else{
cnt++;
j++;
}
}
for(int i=0;i<len;i++){
cnt++;
}
cout<<cnt;
}
int main() {
char a[1000];
cin.getline(a,1000);
countpall(a);
return 0;
}