Check if an array element is concatenation of two elements from another array | C # program for the above approach ; 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 ; 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
using System ; class GFG { static void findConcatenatedNumbers ( int [ ] a , int [ ] b ) { bool ans = true ; int n1 = a . Length ; int n2 = b . Length ; int [ ] cnt = new int [ 100000 ] ; for ( int i = 0 ; i < n1 ; i ++ ) { cnt [ a [ i ] ] = 1 ; } for ( int i = 0 ; i < n2 ; i ++ ) { int left = b [ i ] ; int right = 0 ; int mul = 1 ; while ( left > 9 ) { right += ( left % 10 ) * mul ; left /= 10 ; mul *= 10 ; if ( cnt [ left ] == 1 && cnt [ right ] == 1 ) { ans = false ; Console . Write ( b [ i ] + " ▁ " ) ; } } } if ( ans ) Console . Write ( " - 1" ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 2 , 34 , 4 , 5 } ; int [ ] b = { 26 , 24 , 345 , 4 , 22 } ; findConcatenatedNumbers ( a , b ) ; } }