flag=0; for(int i=0;i<n-1;i+=2) { if(arr[0]!=arr[1]) { flag=1; break; } }
if(! flag) cout<<arr[n-1]; else cout<<arr[i]; T(N) : O(n/2) More can be done using 2 pointer , 1st going forward , 2nd in reverse. You can use xor operation in pairing too ..from moving back as well as moving front, Binary search is of no use ! -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.