Simple Java Solution but not very efficient beats 77%


  • 1
    public boolean isAnagram(String s, String t) {
            char[] sch = s.toCharArray();
            char[] tch = t.toCharArray();
            
            Arrays.sort(sch);
            Arrays.sort(tch);
            if((new String(sch)).equals(new String(tch))) return true;
            return false;
        }

Log in to reply
 

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