Simple solution


  • 0
    S
     public boolean isAnagram(String s, String t) {
           if ( s.length() != t.length() ) {
               return false;
           }
           
           char[] sArr = s.toCharArray();
           char[] tArr = t.toCharArray();
           
           Arrays.sort(sArr);
           Arrays.sort(tArr);
           return Arrays.equals(sArr, tArr);
        }

Log in to reply
 

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