We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<bits/stdc++.h>usingnamespacestd;stringa="abcdefghijklmnopqrstuvwxyz";//dr0opy intmain(){intn;cin>>n;strings;cin>>s;intmaxi=0;//to cal the max length of the possible stringfor(inti=0;i<26;i++){for(intj=i+1;j<26;j++){charx=a[i];chary=a[j];stringt="";for(intk=0;k<n;k++){if(s[k]==x||s[k]==y){t+=s[k];}}//cout<<t<<endl;boolflag=true;for(intf=0;f+1<t.size();f++){if(t[f]==t[f+1]){flag=false;break;}}intts=t.size();if((flag)&&(ts>1))maxi=max(maxi,ts);}}cout<<maxi<<endl;return0;}
it took me 4 months and finally did it ;)
Cookie support is required to access HackerRank
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 →
it took me 4 months and finally did it ;)