[algogeeks] Re: Missing numbers

2009-08-01 Thread Devi G
@Vivek I had told abt tat border case already once.. Suppose the two missin numbers are greater than n, then m==0 when exitin the loop. So they will be n+1 and n+2 only. in case, one of the missin numbers is greater than n, then m==1, and can be simply found by subtracting the (array_sum+x[0] )

[algogeeks] Re: Missing numbers

2009-07-31 Thread Devi G
The logic is actually simple. Tot if we mark in some way an element when it's scanned, we can find the missing numbers in the second scannin. 3,5,1,2,9,10,8,6 When for loop sees '3' it knows elt 3 is there. So multiplies the number at 3rd position by some arbitrary number. (* I've taken the

[algogeeks] Re: Missing numbers

2009-07-30 Thread Devi G
for(i=1; i=n ;i++ ) //for ease of understanding starting the array with 1. { if(a[ i ] n ) continue; else a[ a [ i ] ]*=n; } int x[2], m = 0; for ( int i = 1; i =n ; i++) { if(a[ i ] % n == 0) continue;

[algogeeks] Re: Missing numbers

2009-07-30 Thread Devi G
than n, then m==1, and can be simply found by subtracting the (array_sum+x[0] ) from (sumof 1 to n+2) numbers. On Thu, Jul 30, 2009 at 10:55 PM, Devi G devs...@gmail.com wrote: for(i=1; i=n ;i++ ) //for ease of understanding starting the array with 1. { if(a[ i ] n