i am not sure , but this came to me when i first read it

here is the idea:-
given : 4 5 7 10 12 13

4 should be there boz it is the least.

next is 5 , 5-4 =1 which is less that 4 , so 1 should be there

next is 7 , 7-4 = 3 which is less than 4 , so 3 should be there

next is 10 , 10-4 = 6 which is greater then 4 , so add previous found
elements
i.e 1,3,4 add them 1+3+4 = 8 , add 1 to 8 = 9

now check ,can we use this number(i.e 9 ) and previous found elements (
1,3,4) to
form 10 ( 9 +1) : yes -> so 9 should be there

next is 12 , 12-4 = 8 ( but now greatest element among 1,3,4,9 is 9) and 8
< 9 ,so skip;

next is 13 , 13-4 = 9 same reason for skipping as for number 12 before.


On Tue, Dec 13, 2011 at 10:28 PM, top coder <topcode...@gmail.com> wrote:

> 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
> 4 5 7 10 12 13
>
> o/p:
> 1 3 4 9
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to