https://www.codechef.com/problems/CHEALG

/Can anyone tell me what is going wrong in this code for the problem?
Note: I have included iostream ,algorithm and string
/

#include
#include
#include
using namespace std;
int main() {
unsigned short int inc{},stop{};
cin>>stop;
while(inc<stop){
std::string str,cstr,fs;
cin >> str;
std::string::iterator it1;
fs=str[0];
while(1){
it1=std::find_end(str.begin(), str.end(), fs.begin(), fs.end());
unsigned short int temp=std::count(str.begin(),str.end(),*it1);
cstr+=*it1+to_string(temp);
if(*it1==str.rbegin())
break;
fs=
(++it1);
}
if(cstr.length()<str.length())
cout<<“YES”<<"\n";
else
cout<<“NO”<<"\n";
++inc;
}

return 0;

}

Could you provide link to your submission.

please check you link :frowning:

https://www.codechef.com/viewsolution/34545690

Only @ssjgz seems to be experienced enough to understand you solution.

You are considering sub-sequences but the question ask for sub-strings. So you can’t do sorting here.
for input:
1
aabbaabb

your code gives “YES” but correct output is “NO”.

One friendly advise : It’s a good thing to use stl-algorithms when they make your life easy, but if they are over-complicating your solution you should skip them.

hey there!
I am using sort stl to sort the characters of input string . I have manually tested it’s working . Please provide some code comments or part of code which needs modification.

what output did you get for
1
aabbaabb