Solve anagram in scala