Python is Love!


#1
class Solution:
    def permuteHelper(self, arr, prefix, result):
        if len(arr) == 0:
            result.append(prefix)
        else:
            for i in range(len(arr)):
                # Chose / Explore /Unchose
                self.permuteHelper(arr[:i] + arr[i + 1:], prefix + [arr[i]], result)
                
    # @param A : list of integers
    # @return a list of list of integers
    def permute(self, A):
        result = []
        self.permuteHelper(A, [], result)
        return result