Why it's not passing all the test cases?

@vanshikasharma1645

Sort the array before initializing the values of s and e. e’s values is decided by the distance between the first and the last barn.

If my solution is able to clear your doubt, please mark the query as resolved.

@vanshikasharma1645
You asked the same doubt earlier.
If this works out, please mark it as resolved too