mshubham's blog

By mshubham, 13 years ago, In English

You are given n strings and you have to arrange anagram strings in separate line in order. for example:

Input:

n = 7

aabbcc

acbabc

abccba

bcba

ab

aa

abbc

Output:

aa

aabbcc abccba acbabc

ab

abbc bcba

Explanation: output strings in same lines are anagram in Lexicographically order also strings in different lines are also Lexicographically arranged.

I am trying to solve the problem but my code showing runtime error

here is my code: Anagrams

please help

  • Vote: I like it
  • -10
  • Vote: I do not like it

| Write comment?
»
13 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I don't know where is your mistake but your algorithm is not the best.

»
13 years ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

I dont know ur problem but u could write

bool isAnagram(string s1,string s2){
    sort(s1.begin(), s1.end());
    sort(s2.begin(), s2.end());
    return s1 == s2;
}

instead of ur code

»
13 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I found the correct code.. Here is the correct code

Anagram