Why are we able to compare vector element with string element without initializing the vector? How does it work?
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--) {
string x; cin>>x;
vector<char> a;
for(int i=0;i<x.length();i++) {
int f=0;
for(int j=0;j<a.size();j++) {
if(a[j]==x.at(i)) {
f=1;
break;
}
}
if(f==0)
a.push_back(x.at(i));
}
if(a.size()==2)
cout<<"YES\n";
else
cout<<"NO\n";
}
return 0;
}