Find the element that appears once in an array where every other element appears twice |  ; singleelement function ; Driver code
using System ; using System . Collections ; class GFG { static int singleelement ( int [ ] arr , int n ) { int low = 0 , high = n - 2 ; int mid ; while ( low <= high ) { mid = ( low + high ) / 2 ; if ( arr [ mid ] == arr [ mid ^ 1 ] ) { low = mid + 1 ; } else { high = mid - 1 ; } } return arr [ low ] ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 5 , 4 , 5 , 3 , 4 } ; int size = 7 ; Array . Sort ( arr ) ; Console . WriteLine ( singleelement ( arr , size ) ) ; } }