Please help me figure out the error


  • 0

    def permute(inlist,a, l, r):
    ans=[]
    if l==r:
    print a
    k=a
    inlist.append(k)
    ansf.append(a)
    #ans.append(a)
    else:
    for i in xrange(l,r+1):
    a[l], a[i] = a[i], a[l]
    permute(inlist,a, l+1, r)
    a[l], a[i] = a[i], a[l]
    return inlist

    inlist=[]
    print permute(inlist,a,0,len(a)-1)
    print inlist

    While I print a in if condition of l==r, thw right permutations are visible. But on appending those elements to list, and returning the list .. it doesnt work well


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.