Count of non | Javascript implementation of the above approach ; Function to find the count of the number of strings ; Loop to iterate over the frequency of character of string ; reduce the frequency of current element ; recursive call ; freq [ i ] ++ ; backtrack ; Function to count the number of non - empty sequences ; store the frequency of each character ; Maintain the frequency ; Driver Code ; Function Call
let count = 0 ; function countNumberOfStringsUtil ( freq ) { for ( let i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] > 0 ) { freq [ i ] -- ; count ++ ; countNumberOfStringsUtil ( freq ) ; } } } function countNumberOfStrings ( s ) { let freq = new Array ( 26 ) ; for ( let i = 0 ; i < freq . length ; i ++ ) { freq [ i ] = 0 ; } for ( let i = 0 ; i < s . length ; i ++ ) { freq [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } countNumberOfStringsUtil ( freq ) ; return count ; } let s = " " ; document . write ( countNumberOfStrings ( s ) ) ;