Anagram--Can you tel me what is the problem in my code?When i submit it shows wrong answer...

My solution is here

http://www.codechef.com/viewsolution/3243203

@codecrawler:

ur solution fails for the following case:

Testcase:

1

aaaa aaaa

ur output: NO

actual output:YES

This is because the values of

  • count1=16
  • count2=4

Working code(with some editing): http://www.codechef.com/viewsolution/3243768

Other suggestions:

  • there is an inbuilt function strlen() available to find the length of string
  • add β€˜\n’ to printf(β€œNO”) in len1!=len2 condition
  • u can solve this question by either sorting s1 and s2 then comparing them, or find the frequencey of each alphabet and compare them
1 Like

Thnx a lot.It’s really helpful.

Happy to have helped :slight_smile: