Check whether a given string is Heterogram or not | C # Program to check whether the given string is Heterogram or not . ; traversing the string . ; ignore the space ; if already encountered ; else return false . ; Driver code
using System ; class GFG { static bool isHeterogram ( string s , int n ) { int [ ] hash = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] != ' ▁ ' ) { if ( hash [ s [ i ] - ' a ' ] == 0 ) hash [ s [ i ] - ' a ' ] = 1 ; else return false ; } } return true ; } public static void Main ( ) { string s = " the ▁ big ▁ dwarf ▁ only ▁ jumps " ; int n = s . Length ; if ( isHeterogram ( s , n ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }