Not dynamic programming


#1

int Solution::anytwo(string A) {
map<char, vector> indices;
for(int i=0;i<A.length();i++){
indices[A[i]].push_back(i);
}
for(auto it=indices.begin();it!=indices.end();it++){
if(it->second.size()>2)return 1;
}
for(auto it=indices.begin();it!=indices.end();it++){
if(it->second.size()==2){
for(auto ot=it;ot!=indices.end();ot++){
if(ot->second.size()==2){
if(it->second[0]second[0] && it->second[1]second[1])return 1;
}
}
}
}
return 0;
}