Try to be little more greedy
![;)](./images/smilies/icon_wink.gif)
For example you have 5 numbers : 1 2 3 4 7
first we take 7 1 (highest & lowest)
then the remaining numbers are 2 3 4
now in the remaining list 4 and 2 is the highest and lowest. we will try to put any of these two numbers in our output list's beginning or ending position. things will go like this:
_ 7 1 _
4 at end : _ 7 1 4 --> 3 (abs(1-4))
4 at begin : 4 7 1 _ --> 3
2 at end : _ 7 1 2 --> 1
2 at begin : 2 7 1 _ --> 5
so '2' at the beginning position of the output list gives us best result so we will put it there and the new output list will be: 2 7 1, and the remaining list is off course 3 4.
continue this process until the remaining list is empty and u will got the result..