A little better way would be x + y = p = (n*(n+1))/2 - (sum of all elements of array). x * y = q = n! / (product of all elements of the array).
now solve the quadratic eqn. z^2 - (sum of the roots)z + (product of the roots) = 0 On Mon, Jul 18, 2011 at 5:27 PM, varun pahwa <[email protected]>wrote: > make two equations as . > suppose numbers to be x,y > x + y = p = (n*(n+1))/2 - (sum of all elements of array). > > x^2 + y^2 = q = (n*(n+1)*(2n+1))/6 - (sum of square of all elements of > array). > > so 2*x*y can be calculated as (p^2 - q); > > so, a quad equation is formed as you now (x + y) and (2*xy). > > P.S. :: overflow is not handled. > > Please comment. > > On Mon, Jul 18, 2011 at 5:01 PM, TUSHAR_MCA <[email protected]>wrote: > >> Given an array of size n. It contains numbers in the range 1 to n. >> Each number is present at least once except for 2 numbers. Find the >> missing numbers ? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > > > -- > Varun Pahwa > B.Tech (IT) > 7th Sem. > Indian Institute of Information Technology Allahabad. > Ph : 09793899112 > Official Email :: [email protected] > Another Email :: [email protected] > > People who fail to plan are those who plan to fail. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Regards, Aashish Mann Software Engineer Vihaan Networks Ltd.,Gurgaon -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
