[algogeeks] Re: Missing numbers

2009-08-03 Thread Karthik Singaram Lakshmanan
well..will this work? x + y = SUM(1:N+2) - SUM(array) = a x^2 + y^2 = SUM(1^2:(N+2)^2) - SUM(array.^2) = b so (a^2 - b) = 2xy so xy = (a^2-b)/2 = k (say) now, x + (k/x) = a x^2 + k = ax (x, y) = (a +/- sqrt(a^2-4k))/2 I may not have written the equations correctly (need coffee !!!) but you

[algogeeks] Re: Missing numbers

2009-08-03 Thread Prunthaban Kanthakumar
Here is the right answer: Find the sum of missing numbers. Call it S (this is a easy to do). Now the two missing numbers are such that one is =S/2 and the other is S/2 Have two variables S1 and S2, traverse the array and add everything = S/2 to S1 and S/2 to S2. Now First number = (Sum of