racing horses

this is my link for the code
pls help me…am getting wrong answer for this…thx in advance

You are missing the condition where after sorting, difference between some adjacent elements other than the first two can be minimum.

See this modification applied to your code and it is ACcepted here.