Number of pairs with Pandigital Concatenation | C ++ program to find all Pandigital concatenations of two strings . ; Checks if a given string 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isPanDigital ( string s ) { bool digits [ 10 ] = { false } ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) digits [ s [ i ] - '0' ] = true ; for ( int i = 0 ; i <= 9 ; i ++ ) if ( digits [ i ] == false ) return false ; return true ; } int countPandigitalPairs ( vector < string > & v ) { int pairs = 0 ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) for ( int j = i + 1 ; j < v . size ( ) ; j ++ ) if ( isPanDigital ( v [ i ] + v [ j ] ) ) pairs ++ ; return pairs ; } int main ( ) { vector < string > v = { "123567" , "098234" , "14765" , "19804" } ; cout << countPandigitalPairs ( v ) << endl ; return 0 ; }