Given two unsorted arrays , find all pairs whose sum is x | Function to print all pairs in both arrays whose sum is equal to given value x ; Driver code
def findPairs ( arr1 , arr2 , n , m , x ) : NEW_LINE INDENT for i in range ( 0 , n ) : NEW_LINE INDENT for j in range ( 0 , m ) : NEW_LINE INDENT if ( arr1 [ i ] + arr2 [ j ] == x ) : NEW_LINE INDENT print ( arr1 [ i ] , arr2 [ j ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT arr1 = [ 1 , 2 , 3 , 7 , 5 , 4 ] NEW_LINE arr2 = [ 0 , 7 , 4 , 3 , 2 , 1 ] NEW_LINE n = len ( arr1 ) NEW_LINE m = len ( arr2 ) NEW_LINE x = 8 NEW_LINE findPairs ( arr1 , arr2 , n , m , x ) NEW_LINE