why am i getting WA??

ad-hoc
beginner
problem

#1

Where is my code wrong??It’s giving WA…link text

code:-

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int t;
   cin>>t;
   while(t--)
   {
   	 int i,len,flag=-1,val=1;
   	 char s[10001];
   	 cin>>len;
   	 cin>>s;
   	 for(i=0;i<len;++i)
   	 {
   	 	if(s*=='T')
   	 	{
   	 		if(flag==-1) {cout<<"Invalid

";val=0;break;}
if(flag==1) flag=0;
}
if(s*==‘H’)
{
if(flag==-1) flag=1;
else if(flag==0) flag=1;
else {cout<<"Invalid
";val=0;break;}
}
}
if(val==1&&flag==0) cout<<"Valid
";
else if(val==1&&flag==-1)cout<<"Valid
";
else if(val==1&&flag==1)cout<<"Invalid
";
}
return 0;
}


#2

your code fails for this testcase

1

5

H…TT

answer is Invalid but your code prints Valid.


#3

nice work @vijju123


#4

AC…Thank you!!!