String Question 2
Question 2. Write a Program to check string1 is a anagram of string2 or not.
Program-
import java.util.Arrays; class Solution { public boolean isAnagram(String s, String t) { char[] sChars = s.toCharArray(); char[] tChars = t.toCharArray(); Arrays.sort(sChars); Arrays.sort(tChars); return Arrays.equals(sChars, tChars); } } |