JAVA----Easiest to understand

  • 0

    The basic idea here is to convert two strings to char array, and we are going to sort the arrays.
    Compare two arrays by using a for loop,if the characters are not the same at i, return false.

    public boolean isAnagram(String s, String t) {
            return false;
        char[] sc = s.toCharArray();
        char[] tc = t.toCharArray();
        for(int i=0;i<sc.length;i++){
                return false;
        return true;

    I know it is not the optimal solution and I am willing to modify it. Fight for the interview!

Log in to reply

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