Check if a string is Isogram or not | Java code to check string is isogram or not ; function to check isogram ; loop to store count of chars and check if it is greater than 1 ; if count > 1 , return false ; Driver code ; checking str as isogram ; checking str2 as isogram
class GFG { static boolean check_isogram ( String str ) { int length = str . length ( ) ; int mapHash [ ] = new int [ 26 ] ; for ( int i = 0 ; i < length ; i ++ ) { mapHash [ str . charAt ( i ) - ' a ' ] ++ ; if ( mapHash [ str [ i ] - ' a ' ] > 1 ) { return false ; } } return true ; } public static void main ( String [ ] args ) { String str = " geeks " ; String str2 = " computer " ; if ( check_isogram ( str ) ) System . out . println ( " True " ) ; else System . out . println ( " False " ) ; if ( check_isogram ( str2 ) ) System . out . println ( " True " ) ; else System . out . println ( " False " ) ; } }