My issue
i took array and make A= sorted array of n and then remove n from A and inserted it at index 0
My code
t= int(input())
i=1
while i<=t:
n=int(input())
A=[]
for j in range(1,n+1):
A.insert(j-1,j)
for a in range(len(A)):
print(A[a], end=' ')
print("\n",end='')
A.remove(n)
A.insert(0,n)
B=A
for b in range(len(B)):
print(B[b], end=' ')
print("\n", end='')
i=i+1
Problem Link: Maximum Distance Permutations Practice Coding Problem