title: is this the best anagram checking solution?
body: <p>I am looking for an efficient solution to check if two strings are anagrams, but char table/dictionary checking may not be a good solution for unicode. I have come up a solution, but I don't know how to prove it mathematically correct. The formula is in the express as " (a + b) = (c + d) and a XOR b XOR c XOR d = 0 ==> (a,b) and (c,d) are anagrams". Maybe you can help me. The following is an implementation.</p>
  
  <pre><code>def isAnagram(s1: String, s2: String): Boolean = {
    if (s1.length != s2.length) return false
    else {
      var numVal = 0
      var bitVal = 0
      for (i &lt;- 0 until s1.length) {
        numVal += s1(i) - s2(i)
        bitVal ^= s1(i) ^ s2(i)
      }
  
    return numVal == 0 &amp;&amp; bitVal == 0
  }
  </code></pre>