Find the number of strings formed using distinct characters of a given string | Function to return the factorial of n ; Function to return the count of all possible strings that can be formed with the characters of the given string without repeating characters ; To store the distinct characters of the string str ; Driver code
function fact ( n ) { let fact = 1 ; for ( let i = 1 ; i <= n ; i ++ ) fact *= i ; return fact ; } function countStrings ( str , n ) { let distinct_char = new Set ( ) ; for ( let i = 0 ; i < n ; i ++ ) { distinct_char . add ( str [ i ] ) ; } return fact ( distinct_char . size ) ; } let str = " " ; let n = str . length ; document . write ( countStrings ( str , n ) ) ;