Modify array of strings by replacing characters repeating in the same or remaining strings | C # program for the above approach ; Function to remove duplicate characters across the strings ; Stores distinct characters ; Size of the array ; Stores the list of modified strings ; Traverse the array ; Stores the modified string ; Iterate over the characters of the modified string ; If character is already present ; Insert character into the Set ; Print the list of modified strings ; Print each string ; Driver Code ; Given array of strings ; Function Call to modify the given array of strings
using System ; using System . Collections . Generic ; class GFG { static void removeDuplicateCharacters ( string [ ] arr ) { HashSet < int > cset = new HashSet < int > ( ) ; int n = arr . Length ; List < string > Out = new List < string > ( ) ; foreach ( string str in arr ) { string out_curr = " " ; foreach ( char ch in str . ToCharArray ( ) ) { if ( cset . Contains ( ch ) ) continue ; out_curr += ch ; cset . Add ( ch ) ; } if ( out_curr . Length != 0 ) Out . Add ( out_curr ) ; } for ( int i = 0 ; i < Out . Count ; i ++ ) { Console . Write ( Out [ i ] + " ▁ " ) ; } } static public void Main ( ) { string [ ] arr = { " Geeks " , " For " , " Geeks " , " Post " } ; removeDuplicateCharacters ( arr ) ; } }