public boolean check(String a, String b) {
    if (a == null || b == null) {
      throw new IllegalArgumentException("You can't use null Strings as input.");
    }
    if (a.length() != b.length()) {
      return false;
    }
    char[] charsA = a.toCharArray();
    Arrays.sort(charsA);
    char[] charsB = b.toCharArray();
    Arrays.sort(charsB);
    return Arrays.equals(charsA, charsB);
  }
Iterative algorithm to solve this problem. Two words are anagrams just if contains the same
number of letters. Using this property, we are going to sort and compare the letters inside
the array.  The complexity order of this algorithm is O(N*Log(N)) where N is the number of
letters in the largest word. In space terms, the complexity order of this algorithm is O(N).
src/main/java/com/github/pedrovgs/problem29/AreAnagrams.java