this one is with MINUS operation....
int n = 1Lakh;
int  FindMiss( int X[])
{
    int k  = n;
    int j =  n - 1;
    for(i=0; i < n; i++)
   {
       k -= X[i];
       while ( k > 0){
          k += j;
          j--;
       }
  }

while ( j >= 0 ){
 k += j;
 j--;
}

return k+ (1) ; //adding 1 is for your -1 for missing number in X[]


}


Dhyanesh wrote:
> This problem has already been solved on this group before. See previous
> threads for title "Missing Numbers". It is done by XORing.
>
> -Dhyanesh
>
> On 12/20/05, Uppala Babu <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >  you have been  a long input stream of 1 to 1Lakh number  in which one
> > number is missing and in place of that number -1 is present, input comes in
> > random order, you have to find the number which is missing and also at what
> > position in the input stream this -1 occurs.
> >
> >
> > Regards
> > Babu
> >
> >

Reply via email to