set to store the Strings
HashSet < String > st = new HashSet < String > ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) { String ans = " " ; for ( int j = i ; j < s . Length ; j ++ ) { ans += s [ j ] ;