Why this isn't working? Please help

Why this isn’t working?
Please help.


Hey @cbcao263
Please explain ur logic

I first inserted char of first string in map and then matched with other strings and if it is present in both then I inserted in main map

Say we had B E L L A , … LABEL, … A
as 3 strings
Now u put BELLA in m1
Now for 2nd string u check and put L A B E L in main
Now for 3rd string its already there so no need
So u will get ans as LABE but actual ans is A only

   for(auto itr=main.begin();itr!=main.end();itr++)
    {
        char y=itr->first;
        string x="";
        x+=y;
        res.push_back(x);
    }

Use this in ur code to get it working
And then try to debug logically


sir ab shi hain?

Syntatically shi h but logically u have to still work on it
Think of each string as a multiset and u have to take intersection of all sets

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.