@SAMM your algo does not work first thing why are you xoring the xor of list with only 1-5 range of numbers is 0 - 2^32 ?? if you are xoring with min to max of array the you can try out following case where your algorithm fails
{1,3,1,3,3} this question is already been discussed i think .......just search it on the group :) On Mon, Jul 18, 2011 at 5:03 PM, SAMMM <somnath.nit...@gmail.com> wrote: > Because I am finding the element in the range of 0 to 4 , total 5 > elements And the loop is iterating for the interval of 0 - 3 , so to > XOR 4 also (last index) . I have done that . Got it /???? > > On Jul 18, 3:02 pm, sagar pareek <sagarpar...@gmail.com> wrote: > > @SAMM > > please explain why u are using res^=j; ? > > i m not good in bits operations... > > > > > > > > > > > > On Mon, Jul 18, 2011 at 1:24 PM, SAMMM <somnath.nit...@gmail.com> wrote: > > > /* > > > INPUT:- > > > 5 --> NO of testr cases > > > 0 > > > 1 > > > 4 > > > 5 > > > 3 > > > OUTPUT:- > > > 2 > > > */ > > > > > #include<stdio.h> > > > #include<stdlib.h> > > > int main() > > > { > > > int n=0,j=0,t=0,res; > > > res=0L; > > > scanf("%d",&t); > > > while(t--) > > > { > > > scanf("%d",&n); > > > res^=n;res^=j; > > > j++; > > > } > > > printf("%d\n",res^j); > > > return 0; > > > } > > > > > Example :-- > > > 4 > > > 0 > > > 4 > > > 1 > > > 3 > > > > > Output:- > > > 2 (Because the in the list 0 to 4 , element 2 is missing ) > > > > > -- > > > 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. > > > > -- > > **Regards > > SAGAR PAREEK > > COMPUTER SCIENCE AND ENGINEERING > > NIT ALLAHABAD- Hide quoted text - > > > > - Show quoted text - > > -- > 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. > > -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.