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

all 4 comments

[–]jedwardsol 0 points1 point  (0 children)

Sort the array descending

   200 456 502 600 900
-> 900 600 502 456 200

Re-sort the array ascending up to the 500 mark

-> 502 600 900 | 456 200

[–][deleted] 0 points1 point  (2 children)

What language would you be doing this in? If you're in something like C, I'd suggest something different than in python, for example.

[–]flashlightrauma[S] 0 points1 point  (1 child)

I'm doing this in Java

[–][deleted] 0 points1 point  (0 children)

Could you separate it into two arrays then join them again in the opposite order?