text: Check duplicates in a stream of strings | C # implementation of the approach ; Function to insert the names and check whether they appear for the first time ; To store the names of the employees ; If current name is appearing for the first time ; Driver code
code: using System ; using System . Collections . Generic ; class GFG { static void insertNames ( String [ ] arr , int n ) { HashSet < String > set = new HashSet < String > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! set . Contains ( arr [ i ] ) ) { Console . Write ( " No STRNEWLINE " ) ; set . Add ( arr [ i ] ) ; } else { Console . Write ( " Yes STRNEWLINE " ) ; } } } public static void Main ( String [ ] args ) { String [ ] arr = { " geeks " , " for " , " geeks " } ; int n = arr . Length ; insertNames ( arr , n ) ; } }