Count of Palindromic Strings possible by swapping of a pair of Characters |  ; Function to return the count of possible palindromic strings ; Stores the frequencies of each character ; Stores the length of the string ; Increase the number of swaps , the current character make with its previous occurrences ; Increase frequency ; Driver Code
/ *	JavaScript program to implement the above approach function findNewString ( s ) { var ans = 0 ; var freq = new Array ( 26 ) . fill ( 0 ) ; var n = s . length ; for ( let i = 0 ; i < n ; i ++ ) { ans += freq [ s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] ; freq [ s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] += 1 ; } return ans ; } var s = " " ; document . write ( findNewString ( s ) ) ;