You are given an array containing positive integers. All the integers occur even number of times except one. Find this special integer.
Click for Solution
  • A void main()
    {
    int a[10][2],flag=0,n=0;
    int arr[]={2,3,6,7,2,3,3,3,3,7,7,3,6,6,6};

    for(int i=0;i<10;i++)
    a[i][1]=0;

    for(int i=0;i<15;i++)
    {
    for(int j=0;j<n;j++)
    {
    if(a[j][0]==arr[i])
    {
    flag=1;
    a[j][1]++;
    break;
    }
    }
    if(flag==0)
    {
    a[n][0]=arr[i];
    a[n][1]=1;
    n++;
    }
    flag=0;
    }

    for(int i=0;i<10;i++)
    {
    if(a[i][1]%2!=0)
    {
    cout<<a[i][0];
    break;
    }
    }

    }

  • A i think,we can xor all elements of given array


[Insert Code]