WA in NAME2

#include
#include

                using namespace std;


                class test{
                public:
                    string f,l;
                };

                bool ispresent( char ch , string &k )
                {

                    for(int i=0;i<k.size();i++)
                    {
                        if(k.at(i)==ch)
                        {
                            k.erase( (k.begin()+i) );
                            return true;
                            break;
                        }
                    }

                    return false;


                }


                int main(){
                    std::ios_base::sync_with_stdio(false);
                    string::iterator it;
                    int t;
                    bool c;
                    cin>>t;
                    test s[t];
                    for(int i=0;i<t;i++)
                        cin>>s[i].f>>s[i].l;

                     for(int i=0;i<t;i++)
                     {
                         c=true;
                        sort(s[i].f.begin() , s[i].f.end());
                        it= unique(s[i].f.begin() , s[i].f.end());
                        while(  (count(s[i].f.begin(), s[i].f.end() , *it ) <= count(s[i].l.begin(), s[i].l.end() , *it ))   && (it>=s[i].f.begin()) )
                        {
                            it--;
                        }

                         if(it==(s[i].f.begin()-1))
                            cout<<"YES";
                         else
                            cout<<"NO";

                         cout<<endl;
                     }



                return 0;
                }

getting WA , any hopes? , My submission id : 4093892

Thanks

Hello Abhishek,
You are getting wrong answer because, you are checking only first string into second. Question says that, either first presents in second or second presents in first string. So you need to check for both string or simply check for string with lower length in string with larger length.
Try the cases:
case 1 : johanna john ,
case 2 : irak ira ,
both should give “YES” output.
If you have any query, then you can refer my solution : http://www.codechef.com/viewsolution/4102565
Good luck…!!!

//