@jalaj jaiswal

given array contain 3,6 both r unique.
Is this the exact question?

if array is 6,3,4,1,4,5,6,1,5 than we can solve using xor properties.

int a,b=5;
a=b^b;       //value of a is 0 convert in binery form and do u will get
a=0^a;        //value of a is a itselt

Program:

#include<stdio.h>
int unique(int array[],int size)
{
        int i,x=0;
        for(i=0;i<size;i++)
        x^=array[i];
        return x;
}
int main()
{
        int array[]={6,3,4,1,4,5,6,1,5};
        int size=sizeof(array)/sizeof(array[0]);
        printf("%d",unique(array,size));
}


this will give the result bcoz

0^6^3^4^1^4^5^6^1^5 = 3
as xor is associative .

On 6/14/10, kunzmilan <kunzmi...@atlas.cz> wrote:
> Write the array as a vector string S, eg
> (1,0,0,0...)
> (0,0,1,0...)
> (0,0,0,1...)
> etc.
> Find the quadratic form S^T.S. On its diagonal, occurences of all
> numbers are counted.
> kunzmilan
>
>
> On 13 čvn, 20:44, jalaj jaiswal <jalaj.jaiswa...@gmail.com> wrote:
>> give an algo to find a unique number in an array
>>
>> for eg a[]={1,3,4,1,4,5,6,1,5}
>>
>> here 3 is the unique number as it occur only once... moreover array
>> contains
>> only 1 unique number
>>
>> --
>> With Regards,
>> Jalaj Jaiswal
>> +919026283397
>> B.TECH IT
>> IIIT ALLAHABAD
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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.

Reply via email to