0
#include<iostream>
#include<string>

using namespace std;
int main()
{

    int n ;
    cin>>n;fflush(stdin); //due to this i was getting error
    string array[100];
    for(int i = 0 ; i < n ; i++)
    {
        getline(cin , array[i]);
    }
    string alternate;
    int deletion = 0;
    for(int i = 0 ; i < n ; i++)
    {
        alternate = array[i];
        for(int j = 0 ; j < alternate.length()-1 ; j++)
        {
            if(alternate[j] == alternate[j+1])
            {
                    deletion++;
            }
        }
        cout<<deletion<<endl;
        deletion = 0;
    }
}

i was doing hackerrank problem but on hackerrank compiler it gives me error of segmentation fault but on my compiler which is dev c++ it was working ...

0 Answers0