An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an isogram. Ignore letter case.
isIsogram “Dermatoglyphics” == true
isIsogram “aba” == false
isIsogram “moOse” == false – ignore letter case
1.
public class MM {
public static boolean method(String str) {
return str.length() == str.toLowerCase().chars().distinct().count();
}
}
2.
public class MM{
public static boolean method(String str){
Set set=new HashSet();
char[] ch =str.toLowerCase().toCharArray();
for(char item:ch){
set.add(item);
}
return set.size()==ch.length;
}
}