Find missing number in another array which is shuffled copy | Returns the missing number Size of arr2 [ ] is n - 1 ; Missing number ' mnum ' ; 1 st array is of size ' n ' ; 2 nd array is of size ' n ▁ - ▁ 1' ; Required missing number ; Driver Code
function missingNumber ( arr1 , arr2 , n ) { let mnum = 0 ; for ( let i = 0 ; i < n ; i ++ ) mnum = mnum ^ arr1 [ i ] ; for ( let i = 0 ; i < n - 1 ; i ++ ) mnum = mnum ^ arr2 [ i ] ; return mnum ; } let arr1 = [ 4 , 8 , 1 , 3 , 7 ] ; let arr2 = [ 7 , 4 , 3 , 1 ] ; let n = arr1 . length ; document . write ( " " + missingNumber ( arr1 , arr2 , n ) ) ;