@@ -0,0 +1,1054 @@
+/*%0AGiven two strings s and t, write a function to determine if t is an anagram of s.%0A%0AFor example,%0As = %22anagram%22, t = %22nagaram%22, return true.%0As = %22rat%22, t = %22car%22, return false.%0A%0ANote:%0AYou may assume the string contains only lowercase alphabets.%0A*/%0Aimport java.io.*;%0Aimport java.util.*;%0A%0Apublic class ValidAnagram %7B%0A%09public static boolean isAnagram(String s, String t) %7B%0A        if(t.length() %3C=0) return true;%0A        if(s.length() %3C=0) return false;%0A        if(s.length() != t.length()) return false;%0A        char%5B%5D ss = s.toCharArray();%0A        char%5B%5D ts = t.toCharArray();%0A        Arrays.sort(ss);%0A        Arrays.sort(ts);%0A        for(int i = 0; i %3C ts.length; i++)%7B%0A            if(ss%5Bi%5D !=  ts%5Bi%5D)%7B%0A                return false;%0A            %7D%0A        %7D%0A        return true;%0A    %7D%09%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09String s = %22cart%22;%0A%09%09String t = %22ctra%22;%0A%09%09boolean res = isAnagram(s, t);%0A%09%09System.out.println(%22Source string: %22 + s);%0A%09%09System.out.println(%22Target string: %22 + t);%0A%09%09System.out.println(%22Is anagram: %22 + res);%0A%09%09return;%0A%09%7D%09%0A%7D%0A

valid anagram