HORSES: Problem Solution Help

[HORSES Problem - CodeChef - Problem Statement](HORSES Problem - CodeChef - Problem Statement)

Algorithm: Sort all horses by ascending order, finding the difference between adjacent elements and store it in a second array, then sort the second array and output the minimum difference - Code is working with the example test case but error when submitting

Link to code - https://www.codechef.com/viewsolution/25509339

https://www.codechef.com/viewsolution/25509439
Here is my solution using your approach…
So your approach is correct!
But you declared a huge array and it is filled with garbage value…
so suppose for huge numbers, the garbage value is lesser that will be printed. This will give the wrong answer or WA.
(PS: I used inbuilt function sort() function to make the solution easier.)