@@ -0,0 +1,959 @@
+package easy;%0A%0Aimport java.util.Arrays;%0A%0Apublic class ValidAnagram %7B%0A    public boolean isAnagram_solution1(String s, String t) %7B%0A        //I even thought about using HashMap to compute their character frequencies respectively and then compare each entry of the two maps, but totally unnecessary.%0A        char%5B%5D schar = s.toCharArray();%0A        char%5B%5D tchar = t.toCharArray();%0A        Arrays.sort(schar);%0A        Arrays.sort(tchar);%0A        return new String(schar).equals(new String(tchar));%0A    %7D%0A    %0A    //another way: altough much slower%0A    public boolean isAnagram_solution2(String s, String t) %7B%0A        if(s == null %7C%7C t == null %7C%7C s.length() != t.length()) return false;%0A        int%5B%5D counts = new int%5B26%5D;%0A        for(int i = 0; i %3C s.length(); i++)%7B%0A            counts%5Bs.charAt(i) - 'a'%5D++;%0A            counts%5Bt.charAt(i) - 'a'%5D--;%0A        %7D%0A        for(int i : counts)%7B%0A            if(i != 0) return false;%0A        %7D%0A        return true;%0A    %7D%0A%7D%0A

valid anagram