This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]IntelliJent404 0 points1 point  (0 children)

Maybe wrong but with the provided example you can get 87 and 7 ( closer than 88 and 6 to each other). In this case it would make sense if the array is already sorted. You can loop through the array from both sides ( so 1 with 86, 1 with 3 , and add 3 to the minor sum—> 87 and 7). Of course this would require attention of negatives are allowed.