package seleniumrepo;
import java.util.Arrays;
/*
* Check whether two strings are anagram of each other
* Ex: LISTEN <=> SILENT, TRIANGLE <=> INTEGRAL, HEART <=> EARTH
*/
public class Anagram {
public static void main(String[] args) {
String s="LISTEN";
String s1="SILENT";
char[] ch=s.toCharArray();
char[] ch1=s1.toCharArray();
Arrays.sort(ch);
Arrays.sort(ch1);
if(Arrays.equals(ch, ch1)){
System.out.println("True - Given number is words are anagrom of each other");
}else{
System.out.println("False - Given number is words are not anagrom of each other");
}
}
}
import java.util.Arrays;
/*
* Ex: LISTEN <=> SILENT, TRIANGLE <=> INTEGRAL, HEART <=> EARTH
*/
public class Anagram {
public static void main(String[] args) {
String s="LISTEN";
String s1="SILENT";
char[] ch=s.toCharArray();
char[] ch1=s1.toCharArray();
Arrays.sort(ch);
Arrays.sort(ch1);
if(Arrays.equals(ch, ch1)){
System.out.println("True - Given number is words are anagrom of each other");
}else{
System.out.println("False - Given number is words are not anagrom of each other");
}
}
}
0 comments:
Post a Comment