Help me in solving MAX_DIFF problem

My issue

I am getting the time limit exceeded result even when I use for loop

My code

# cook your dish here
t=int(input())
for i in range(t):
    n,s=[int (x) for x in input().split()]
    maxdiff=-1
    for i in range(min(n,s)+1):
        second=s-i;
        l=[i,second]
    print(abs(l[0]-l[1]))
    
    

Problem Link: CodeChef: Practical coding for everyone

@kartikteja
U r getting tle because for nested loop in test case loop u have to code it in O(1) time complexity. because of the constraints size is high

1 Like

Thank you, dpcoder_007