Find index of an extra element present in one sorted array | Returns index of extra element in arr1 [ ] . n is size of arr2 [ ] . Size of arr1 [ ] is n - 1. ; Driver code ; Solve is passed both arrays
function findExtra ( arr1 , arr2 , n ) { for ( let i = 0 ; i < n ; i ++ ) if ( arr1 [ i ] != arr2 [ i ] ) return i ; return n ; } let arr1 = [ 2 , 4 , 6 , 8 , 10 , 12 , 13 ] ; let arr2 = [ 2 , 4 , 6 , 8 , 10 , 12 ] ; let n = arr2 . length ; document . write ( findExtra ( arr1 , arr2 , n ) ) ;