My java solution


  • 7
    S

    I know it should be O(NlgN) solution. Just offer you another way.

       public class Solution {
            public boolean isAnagram(String s, String t) {
                char[] schar = s.toCharArray();
                char[] tchar = t.toCharArray();
                Arrays.sort(schar);
                Arrays.sort(tchar);
                s = new String(schar);
                t = new String(tchar);
                return s.equals(t);
            }
        }

  • 0
    D

    s & t should be checked for avoid nullexception occurred.


Log in to reply
 

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