Блог пользователя mshubham

Автор mshubham, 13 лет назад, По-английски

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

  • Проголосовать: нравится
  • -10
  • Проголосовать: не нравится

»
13 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
13 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

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 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

Anagram