Check if an array element is concatenation of two elements from another array | Function to find elements present in the array b [ ] which are concatenation of any pair of elements in the array a [ ] ; Stores if there doesn 't any such  element in the array brr[] ; Stored the size of both the arrays ; Store the presence of an element of array a [ ] ; Traverse the array a [ ] ; Traverse the array b [ ] ; Traverse over all possible concatenations of b [ i ] ; Update right and left parts ; Check if both left and right parts are present in a [ ] ; Driver Code
function findConcatenatedNumbers ( a , b ) { var ans = true ; var n1 = a . length ; var n2 = b . length ; var cnt = new Map ( ) ; for ( var i = 0 ; i < n1 ; i ++ ) { cnt . set ( a [ i ] , 1 ) ; } for ( var i = 0 ; i < n2 ; i ++ ) { var left = b [ i ] ; var right = 0 ; var mul = 1 ; while ( left > 9 ) { right += ( left % 10 ) * mul ; left = parseInt ( left / 10 ) ; mul *= 10 ; if ( cnt . has ( left ) && cnt . has ( right ) ) { ans = false ; document . write ( b [ i ] + " " ) ; } } } if ( ans ) document . write ( " " ) ; } var a = [ 2 , 34 , 4 , 5 ] ; var b = [ 26 , 24 , 345 , 4 , 22 ] ; findConcatenatedNumbers ( a , b ) ;