Append two elements to make the array satisfy the given condition | Java implementation of the approach ; Function to find the required numbers ; Find the sum and xor ; Print the required elements ; Driver code
class GFG { static void findNums ( int arr [ ] , int n ) { int S = 0 , X = 0 ; for ( int i = 0 ; i < n ; i ++ ) { S += arr [ i ] ; X ^= arr [ i ] ; } System . out . println ( X + " ▁ " + ( X + S ) ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 7 } ; int n = arr . length ; findNums ( arr , n ) ; } }