1262559 | CodeChef Please help me! I'm not very good at programming

Hello, I’ve tried this problem on my Python app, and according to what my inputs and outputs are, when submitting, it should be successful. Could anyone please help me? It would mean a lot. Thanks!

Here is my code:
T = int(input())
for i in range(T):
N = int(input())
L = [int(N) for N in input().split()]
T = []
total = 0
total = int(max(T)) - int(min(T))

Your output is 2nd min-1st min in array , but what if the array is [1,10,11,15,17] your output will be 10-1=9 but the required and is 11-10=1.
What you can do is sort the array and then check the difference between 2 consecutive elements, ans will be minimum of these differences.:grinning:


Ok, thanks so much!

Happy coding :slightly_smiling_face:

1 Like