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
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9hAhlyHKcsAhYxetibLXH-VMxifPxWNog2fFiIVHhLEOfTFH78mSKQPwTHZF4sNlY0GeDvvTJScZcDfV6wznJHlKIyJVJt9xx_BGZw4VZ3FSDxoAMNLx2TG-ZhHr6kw97Zv3gN8aHfpw/s1600/ezgif-1-0205ef5f5236.gif)
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