I have code this problem. I am also getting same partial correct solution. Can any one help with this solution?
# cook your dish here
def main():
for T in range(int(input())):
N,K = list(map(int,input().split()))
segment = dict()
max_segment_length = 0
for i in input().split():
if int(i)<=K :
if segment.get(i) is None:
if len(segment)+1 < K:
segment[i] = 1
else:
# print(segment)
t = sum(segment.values())
max_segment_length= max(max_segment_length , t)
segment = dict()
segment[i] = 1
else:
segment[i] += 1
# print(segment)
t = sum(segment.values())
max_segment_length= max(max_segment_length , t)
print(max_segment_length)
if __name__ == '__main__':
main()