Efficiently check if a string has all unique characters without using any additional data structure | Driver code
import java . util . Arrays ; class GFG { static boolean unique ( String s ) { Arrays . sort ( s . toCharArray ( ) ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i + 1 ) ) { return false ; } } return true ; } public static void main ( String [ ] args ) { if ( unique ( " abcdd " ) == true ) { System . out . println ( " String ▁ is ▁ Unique " ) ; } else { System . out . println ( " String ▁ is ▁ not ▁ Unique " ) ; } } }