Find the element that appears once in an array where every other element appears twice | C # program to find the array element that appears only once ; Return the maximum Sum of difference between consecutive elements . ; Do XOR of all elements and return ; Driver code
using System ; class GFG { static int findSingle ( int [ ] ar , int ar_size ) { int res = ar [ 0 ] ; for ( int i = 1 ; i < ar_size ; i ++ ) res = res ^ ar [ i ] ; return res ; } public static void Main ( ) { int [ ] ar = { 2 , 3 , 5 , 4 , 5 , 3 , 4 } ; int n = ar . Length ; Console . Write ( " Element ▁ occurring ▁ once ▁ is ▁ " + findSingle ( ar , n ) + " ▁ " ) ; } }