Find index of an extra element present in one sorted array | C # program to find an extra element present in arr1 [ ] ; 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
using System ; class GfG { static int findExtra ( int [ ] arr1 , int [ ] arr2 , int n ) { for ( int i = 0 ; i < n ; i ++ ) if ( arr1 [ i ] != arr2 [ i ] ) return i ; return n ; } public static void Main ( ) { int [ ] arr1 = { 2 , 4 , 6 , 8 , 10 , 12 , 13 } ; int [ ] arr2 = { 2 , 4 , 6 , 8 , 10 , 12 } ; int n = arr2 . Length ; Console . Write ( findExtra ( arr1 , arr2 , n ) ) ; } }