Number of pairs with Pandigital Concatenation | Java 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
import java . io . * ; import java . util . * ; class GFG { static ArrayList < String > v = new ArrayList < String > ( ) ; static int isPanDigital ( String s ) { int digits [ ] = new int [ 10 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) digits [ s . charAt ( i ) - ( int ) '0' ] = 1 ; for ( int i = 0 ; i <= 9 ; i ++ ) if ( digits [ i ] == 0 ) return 0 ; return 1 ; } static int countPandigitalPairs ( ) { int pairs = 0 ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) for ( int j = i + 1 ; j < v . size ( ) ; j ++ ) if ( isPanDigital ( v . get ( i ) + v . get ( j ) ) == 1 ) pairs ++ ; return pairs ; } public static void main ( String args [ ] ) { v . add ( "123567" ) ; v . add ( "098234" ) ; v . add ( "14765" ) ; v . add ( "19804" ) ; System . out . print ( countPandigitalPairs ( ) ) ; } }