def search(l,pos1,pos2,a):
for i in range(pos1,pos2+1):
if l[i]==a:
return i
return -1
t=int(input())
for i in range(0,t):
n=int(input())
l=list(map(int,input().split()))
f1=set(l)
#set identifies distinct elements and store in a sorted way
f=[]
for k in f1:
f.append(k)
for i in range(0,n):
if l[i]==f[0]:
curr=i
break
x=1
m=1
while(x<len(f)):
temp=search(l,curr+1,n-1,f[x])
if temp==-1:
m=m+1
temp=search(l,0,curr-1,f[x])
curr=temp
x=x+1
else:
curr=temp
x=x+1
print(m)
Even after testing all the TCs i can think of and also the TCs presented in the editorial i am not able to find a mistake.
The code above gives a WA, please suggest changes/TCs so that i can understand what i am doing wrong.
My solution link( if req ): CodeChef: Practical coding for everyone
question link: RECNDROT Problem - CodeChef