Contiguous unique substrings with the given length L | C # implementation for above approach ; Function to print the unique sub - String of length n ; set to store the Strings ; if the size of the String is equal to 1 then insert ; inserting unique sub - String of length L ; Printing the set of Strings ; Driver Code ; Function calling
using System ; using System . Collections . Generic ; class GFG { static void result ( String s , int n ) { 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 ] ; if ( ans . Length == n ) { st . Add ( ans ) ; break ; } } } foreach ( String it in st ) Console . Write ( it + " ▁ " ) ; } public static void Main ( String [ ] args ) { String s = " abca " ; int n = 3 ; result ( s , n ) ; } }