Determine if a string has all Unique Characters | C # program to illustrate string with unique characters using brute force technique ; If at any time we encounter 2 same characters , return false ; If no duplicate characters encountered , return true ; Driver Code
using System ; public class GFG { static bool uniqueCharacters ( String str ) { for ( int i = 0 ; i < str . Length ; i ++ ) for ( int j = i + 1 ; j < str . Length ; j ++ ) if ( str [ i ] == str [ j ] ) return false ; return true ; } public static void Main ( ) { string input = " GeeksforGeeks " ; if ( uniqueCharacters ( input ) == true ) Console . WriteLine ( " The ▁ String ▁ " + input + " ▁ has ▁ all ▁ unique ▁ characters " ) ; else Console . WriteLine ( " The ▁ String ▁ " + input + " ▁ has ▁ duplicate ▁ characters " ) ; } }