package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/valid-anagram/
 */
public class Problem242 {
    public boolean isAnagram(String s, String t) {
        char[] sChars = s.toCharArray();
        char[] tChars = t.toCharArray();
        Arrays.sort(sChars);
        Arrays.sort(tChars);
        return Arrays.equals(sChars, tChars);
    }
}

@@ -16,34 +16,8 @@
 e;%0A%0A
-import java.util.Arrays;%0A%0A
 /**%0A
@@ -157,23 +157,57 @@
     
-char%5B%5D sChars =
+int%5B%5D counts = new int%5B26%5D;%0A        for (char c :
  s.t
@@ -218,26 +218,30 @@
 rArray()
-;%0A
+) %7B%0A  
         
 char%5B%5D t
@@ -236,23 +236,60 @@
     
-char%5B%5D tChars =
+  counts%5Bc - 'a'%5D++;%0A        %7D%0A        for (char c :
  t.t
@@ -300,17 +300,19 @@
 rArray()
-;
+) %7B
 %0A       
@@ -316,102 +316,179 @@
     
-Arrays.sort(sChars);%0A        Arrays.sort(tChars);%0A        return Arrays.equals(sChars, tChars)
+    counts%5Bc - 'a'%5D--;%0A        %7D%0A        for (int count : counts) %7B%0A            if (count != 0) %7B%0A                return false;%0A            %7D%0A        %7D%0A        return true
 ;%0A  

Update problem 242