##########################################
There is an array (say 'A') with 'n' (n >= 3) distinct positive integers.
There is an array 'B' with n*(n-1)/2 elements which represents the sum of all the possible pairs of two numbers of the array
Example
A = Set of Distinct +ve Integer = {12,2,3,1}
B = Set of sum of any two elements of A = {12+2,12+3,12+1,2+3,2+1,3+1} = {14,15,13,5,3,4}.
Now, if you are given the array B, get the array A.
Subscribe to:
Post Comments (Atom)
2 comments:
Find n first using b's length = (n*(n-1))/2. Assume n number of variables(like a,b,c,d...(n numbers)) and substitute like a+b=first element in the array B, a+c=2nd element in B. Solve the rsultant equations.
It is not generic solution ,
Think that u r array size is 1000
then u ll get 1000 equation , ???
then solving this is cumbersum
Post a Comment