My issue
Where is my wrong ?
My code
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
std::cin >> t;
while(t--)
{
int n,ch=0,ct=0;
cin>>n;
string s,str;
cin>>s;
for(int i=0;i<s.size();i++)
{
if(s[i]=='H'){ch++;
str+=s[i];}
if(s[i]=='T'){ct++;
str+=s[i];}
}
int f=0;
for(int i=0;i<str.size();i++){
if(str[i]==str[i+1] || ch!=ct){
f=1;break;
}
}
if(f==0)std::cout << "Valid" << std::endl;
else std::cout << "Invalid" << std::endl;
}
return 0;
}
Problem Link: SNAKPROC Problem - CodeChef