How to check if two strings are a valid anagram?
An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
class Solution {
public boolean isAnagram(String s, String t) {
char[] arrS = s.toCharArray();
char[] arrT = t.toCharArray();
Arrays.sort(arrS);
Arrays.sort(arrT);
String Snew = new String(arrS);
String Tnew = new String (arrT);
if(Snew.equals(Tnew)){
return true;
}
else return false;
}
}