Problem in appending result to list in python


  • 0
    S

    I am new to python and facing problem on how to append 'a'(in code) to new list
    and return .Can someone help me.
    Right now I am printing permutations.

    class Solution(object):

    def permute(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        res=[]
        i=0
        j=len(nums)
        self.permutelist(nums,0,j-1,res)
    def permutelist(self,a,l,r,res):
        if l==r:
           print a
        else:
            for i in range(l,r+1):
                a[l],a[i]=a[i],a[l]
                self.permutelist(a,l+1,r,res)
                a[l],a[i]=a[i],a[l]

Log in to reply
 

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