RIT01 - Editorial

Problem Link : - [http://www.codechef.com/CODE2015/problems/RIT01]

Author :- [http://www.codechef.com/users/dvlpr_expert]

Tester :- [http://www.codechef.com/users/dvlpr_expert]

Editorialist :- [http://www.codechef.com/users/dvlpr_expert]

DIFFICULTY :- SIMPLE

PREREQUISITES :- Maths,String

PROBLEM :-

Deepak like strings which are in flip flop in nature. For example, he likes XYXYX, while he doesn’t like XXYX. Now he want to convert every string into a string which he likes. for this, he only delete the character in the string.

Now find the minimum number of delete operation which is required to covert a string that deepak likes.

EXPLANATION :-

The string should appear in the alternative form of ‘X’ and ‘Y’. And if it occurs together then deletion is done till the another character does not occur in the string.

NOTE :- The input string contain only ‘X’ and ‘Y’ character.

SOLUTION :-

C++ :-

#include <bits/stdc++.h>

using namespace std;

int main()
{
int t=0;

   scanf("%d",&t);

    while(t--)
    {

    	string s;

    	int x[100001],y[100001],i=0,X=0,Y=0;

    	cin "s";

    	for(i=0;s[i];i++)

    	if(s[i]=='X')X++;

    	else Y++;

    	if(X==s.size() || Y==s.size())

    	cout "s.size()-1";

    	else
    	{

    		int c=0;

    		for(i=0;i<s.size()-1;i++)

    		if(s[i]==s[i+1])

    		c++;

    		cout "c";
    	}
    	
    }

return 0;
}

//