Modify array of strings by replacing characters repeating in the same or remaining strings | 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 ; Given array of strings ; Function Call to modify the given array of strings
function removeDuplicateCharacters ( arr ) { var cset = new Set ( ) ; var n = arr . length ; var out = [ ] ; arr . forEach ( str => { var out_curr = " " ; str . split ( ' ' ) . forEach ( ch => { if ( ! cset . has ( ch ) ) { out_curr += ch ; cset . add ( ch ) ; } } ) ; if ( out_curr . size != 0 ) out . push ( out_curr ) ; } ) ; for ( var i = 0 ; i < out . length ; i ++ ) { document . write ( out [ i ] + " " ) ; } } var arr = [ " " , " " , " " , " " ] ; removeDuplicateCharacters ( arr ) ;