Search code examples
stringalgorithmmathproof

Two strings are anagrams of each other if and only if the sum and product of the characters of the strings are same. How?


I was reading an algorithmic problem at http://learn.hackerearth.com/question/314/finding-non-anagramic-strings-in-a-list/

I came across the following claim:

Two strings (of same size) are anagrams of each other if and only if the sum and product of the characters of the two strings are same (treat A => 1, B => 2, ..., Z => 26).

I tried to prove this but I failed. Can someone prove this claim?


Solution

  • The claim is really false. Following is a counter example.

    • ABBI: Sum = 14, Product = 36
    • AAFF: Sum = 14, Product = 36