Problem on code

What is the problem with the code?

n = int(input())
l = [int(i) for i in input().split()]
k = int(input())

def duplicate(l, k):
d = {}

for i in range(len(l)):
    if l[i] not in d.keys():
        d[l[i]] = i
    else:
        dist = i - d[l[i]]
        d[l[i]] = dist
        if (dist<=k):
            print("true")
            return

print("false")

duplicate(l, k)

I’m getting wrong answer for most of the test cases

hey ur code seems to be correct
the test case file are corrupted
i have reported it to the team
will get back to u soon after i get updated

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.