My issue
in the final if conditions why is it necessary a==sorted(b) when the output can be displayed using c
My code
t=int(input())
for _ in range(t):
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
c=0
t=0
s=sorted(a)
for i in range(0,n-1):
if a[i]<=a[i+1]:
continue
else:
c+=1
t=a[i]
a[i]=a[i+1]
a[i+1]=t
if (c<=1 or c==0) and a==s :
print("yes")
else:
print("no")
'''c=0
for i in range(0,n-1):
if a[i]!=b[i]:
a[i],a[i+1]=b[i],b[i+1]
c+=1
if (c==1 or c==0) and a==b:
print("yes")
else:
print("no")
'''
Problem Link: PSEUDOSORT Problem - CodeChef