Function to return a set of all substrings of given string which have length less than or equal to k
set < string > presentSubstring ( string s , int k ) { set < string > st ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { string s1 = " " ; for ( int j = 0 ; j < k && i + j < n ; j ++ ) { s1 . push_back ( s [ i + j ] ) ; st . insert ( s1 ) ; } } return st ; }