class Solution { // Function is to check whether two strings are anagram of each other or not. public static boolean areAnagrams(String s1, String s2) { // Your code here //Sunill //llinuS //first we will convert this string into array //we will sort the array //we will connvert again array into String //then we will check wheather both the Strings are equal or not char arr1[]=s1.toCharArray(); char arr2[]=s2.toCharArray(); Arrays.sort(arr1); Arrays.sort(arr2); s1=""; s2=""; // e e g k s // e e g k s for(Character ch:arr1){ s1=s1+ch+""; } for(Character ch:arr2){ s2=s2+ch+""; } if(s1.equals(s2)){ return true; }else{ return false; } } } ================================================================== class Solution{ int findFrequency(int Arr[], int X){ //create am map //key will be the actual number and value will be frequency //who so ever key equal to X print its value //first we need to check wheather the key is already there in Map or not //containsKey Map hm=new HashMap<>(); HashMap hm=new HashMap<>(); for(Integer i:Arr){ if(hm.containsKey(i)){ int x=hm.get(i); x++; hm.put(i,x); }else{ hm.put(i,1); } } for(Map.Entry me:hm.entrySet()){ if(me.getKey()==X){ return me.getValue(); } } return 0; } }