First time sharing solution.(Java)


  • 0
    S

    import java.util.Arrays;

    public class Solution {

    public boolean isAnagram(String s, String t) {
        String x = sort(s);
        String y = sort(t);
        return (x.equals(y));
    }
    private static String sort(String a){
        String original = a;
        char[] chars = original.toCharArray();
        Arrays.sort(chars);
        String sorted = new String(chars);
        return sorted;
    }
    

    }


Log in to reply
 

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