Number of pairs with Pandigital Concatenation | Checks if a given is Pandigital ; digit i is not present thus not pandigital ; Returns number of pairs of strings resulting in Pandigital Concatenations ; Iterate over all pair of strings ; Driver code
function isPanDigital ( s ) { let digits = new Array ( 10 ) . fill ( false ) ; for ( let i = 0 ; i < s . length ; i ++ ) digits [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] = true ; for ( let i = 0 ; i <= 9 ; i ++ ) if ( digits [ i ] == false ) return false ; return true ; } function countPandigitalPairs ( v ) { let pairs = 0 ; for ( let i = 0 ; i < v . length ; i ++ ) { for ( let j = i + 1 ; j < v . length ; j ++ ) { if ( isPanDigital ( v [ i ] + v [ j ] ) ) { pairs ++ ; } } } return pairs ; } let v = [ " " , " " , " " , " " ] ; document . write ( countPandigitalPairs ( v ) ) ;