What will be the output of abc, cab, bca, dsa, asd, sad ?


  • 8
    A

    what will be the answer if there are more than one group of anagrams.
    eg: abc, cab, bca, dsa, asd, sad
    here there are two groups one is abc, cab, bca and the other one is dsa, asd, sad.


  • 2
    A

    Atul your answer will be the entire vector because it contains 2 groups having more than 1 string.

    If your string is -
    abc, cab, bca, dsa
    then your answer should be abc, cab, bca because for dsa there is only single string.

    For your question -
    abc, cab, bca, dsa, asd, sad
    the answer will be abc, cab, bca, dsa, asd, sad because it contains two groups and in each group there are more than 1 element.

    Abhijeet your batchmate :)


  • 0
    W

    At first, I thought it should return an array of arrays of strings, in which each array of strings contains a group of anagrams. But in C++ default code just sets the return type as
    vector<string> rather than vector< vector<string> >...


  • 0
    A

    Yaa you dont need group the strings differently. Just push it to a vector without considering string belonging to different groups.....


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.