My java solution that solves all unicode characters


  • 1
    E
    public class Solution {
        public boolean isAnagram(String s, String t) {
            if(s.length()!=t.length()) return false;
            int[] chCount = new int[128];
            for(int i : chCount) i=0;
            char[] chS = s.toCharArray();
            char[] chT = t.toCharArray();
            for(char c : chS) chCount[c]++;
            for(char c : chT){
                if(--chCount[c]<0) return false;
            }
            return true;
        }
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.