You are viewing a single comment's thread. Return to all comments →
here is mine
int main() { int len; cin>>len;
string str; cin>>str; int max_len=-1; int no_come=0; string a = "abcdefghijklmnopqrstuvwxyz"; int enter_1=0;
for(int i=0; i<25; i++) { for(int k=i+1; k<26; k++) { char s_1=a[i]; char s_2=a[k];
char str_update[1001]={'0'}; int x1=0; for(int t=0; t<len; t++) { if(s_1==str[t]) { str_update[x1]=str[t]; x1++; } if(s_2==str[t]) { str_update[x1]=str[t]; x1++; } } string str1(str_update); int len1= str1.length(); int wr=0; for(int l=0; l<len1-1; l++) { enter_1=1; if(str1[l]!=str1[l+1]) { } else { wr=1; break; } } if(wr==0 &&len1>=2) { if(len1>max_len) max_len=len1; no_come=1; } }
}
if(no_come==1) cout<<max_len<<endl; else cout<<"0"<<endl;
Seems like cookies are disabled on this browser, please enable them to open this website
Two Characters
You are viewing a single comment's thread. Return to all comments →
here is mine
int main() { int len; cin>>len;
for(int i=0; i<25; i++) { for(int k=i+1; k<26; k++) { char s_1=a[i]; char s_2=a[k];
}
}