Find the element that appears once in an array where every other element appears twice | Return the maximum Sum of difference between consecutive elements . ; Do XOR of all elements and return ; Driver code
function findSingle ( ar , ar_size ) { let res = ar [ 0 ] ; for ( let i = 1 ; i < ar_size ; i ++ ) res = res ^ ar [ i ] ; return res ; } let ar = [ 2 , 3 , 5 , 4 , 5 , 3 , 4 ] ; let n = ar . length ; document . write ( " " + findSingle ( ar , n ) ) ;