include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t–){
string s;
cin>>s;
if(s.length()<3)
cout<<“YES”<<endl;
else{
int t=1;
for(int i=1;i<s.length();i++){
if(s[0]!=s[i])
t=0;
}
if(t==1)
cout<<“YES”<<endl;
else cout<<“NO”<<endl;
}
}
}
The should should not pass some hidden case or there should be an issue in time complexity
1 Like
You are using t as testcases and inside loop too so value of t is getting changed inside to 0 or 1 ig thats one issue here
1 Like
yes it is write you should not allocate same name to two variable
1 Like