Please help me in finding why my code is giving wrong answer on this paticular test case?


#1

A : [ “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”, “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa” ]

The expected return value:

aaaaaaaaaaaaaaaaaaaaaaaaa

Your function returned the following:

aaa

My code-:
unordered_setust;
string res="";
int len=strs.size();
int k=0;
while(true)
{

        for(int i=0;i<strs.size();i++)
        {
            if(k<strs.at(i).length())
            ust.insert(strs.at(i).at(k));
            else
                return res;
        }
        if(ust.size()==1)
            res.push_back(*ust.begin());
        else 
            return res;
        k++;
        ust.clear();
    }
    return res;