Java Solution(8 ms)

  • 0
        public boolean isAnagram(String s, String t) {
           if(s.length() != t.length())
                return false;
            if(s.isEmpty() && t.isEmpty())
                return true;
            return sort(s).equals(sort(t));
        String sort(String str){
            char[] array = str.toCharArray();
            return new String(array);

Log in to reply

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