accepted on geeks but leetcode giving wrong output

what's wrong with this code it is accepted on geeekforgeeks but leetcode is showing wrong output can any one help me out

class Solution:
def nextPermutation(self, nums: List[int]):
arr=nums

    n=len(arr)
    if n<=1:
        return arr
    elif n==2:
        arr[0],arr[1]=arr[1],arr[0]
        return arr
    ind1=0
    ind2=0
    for i in range(n-1,0,-1):
        if arr[i]>arr[i-1]:
            ind1=i-1
            ind2=i
            break
    for i in range(n-1,-1,-1):
        if arr[i]>arr[ind1]:
            arr[i],arr[ind1]=arr[ind1],arr[i]
            break
    arr1=sorted(arr[ind2:n])
    arr=arr[0:ind2]+arr1
    return arr
Comments (0)