Wednesday, December 14, 2011

If pairwise sums of 'n' numbers are given in non-decreasing order identify the individual numbers. If the sum is corrupted print -1 Example: i/p: 4 5 7 10 12 13 o/p: 1 3 4 9


Ted Hopp said...

Shouldn't there be only a single "4" in the input? Four numbers should generate 6 pairwise sums, not 7.

Shashank Mani said...

@Ted Hoop , Yeah by mistake it was multiple 4's , thnx i have updated the same., it can done in O(N^2) , i am wondering for linear algo ?

Anonymous said...

Can you explain how did you do it in O(n^2) .
where n is the number of elements given to us. that is n = (N*(N-1)/2).
where N is the number of elements in final answer.
Please verify its correctness.

jony said...

I'm not able to see the post. Only comments are visible.

Anonymous said...

Am not able to see the program. only the question and comments are visible. I have visited this site in the past and I dint have any issues that time
- Chris