Simple Java solution


  • 2
    H
    public boolean isAnagram(String s, String t) {
        return sort(s).equals(sort(t));
    }
    
    public String sort(String s) {
        char[] result = s.toCharArray();
        java.util.Arrays.sort(result);
        return new String (result);
    }

Log in to reply
 

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