Choose two elements from the given array such that their sum is not present in any of the arrays | Java implementation of the approach ; find maximum element in an array ; Function to find the numbers from the given arrays such that their sum is not present in any of the given array ; Find the maximum element from both the arrays ; Driver code
class GFG { static int max_element ( int a [ ] , int n ) { int m = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) m = Math . max ( m , a [ i ] ) ; return m ; } static void findNum ( int a [ ] , int n , int b [ ] , int m ) { int x = max_element ( a , n ) ; int y = max_element ( b , m ) ; System . out . print ( x + " ▁ " + y ) ; } public static void main ( String args [ ] ) { int a [ ] = { 3 , 2 , 2 } ; int n = a . length ; int b [ ] = { 1 , 5 , 7 , 7 , 9 } ; int m = b . length ; findNum ( a , n , b , m ) ; } }