human
I found an interesting problem on https://leetcode.com/problems/permutations/:
Given a collection of distinct integers, return all possible permutations.

Example:

Input: [1,2,3]
Output:
[
  [1,2,3],
  [1,3,2],
  [2,1,3],
  [2,3,1],
  [3,1,2],
  [3,2,1]
]

I tried it in Python, but could not do it. Can you solve it?

 ... Give me a the Python code you requested?
assistant
#Here is the Python code you requested.

class Solution:
 
     def permute(self, nums):
         """
         :type nums: List[int]
         :rtype: List[List[int]]
         """
         
         res = []
         
         self.dfs(nums, [], res)
         
         return res
             
     def dfs(self, nums, path, res):
         if not nums:
             res.append(path)
         
         for i in range(len(nums)):
             self.dfs(nums[:i] + nums[i+1:], path+[nums[i]], res)