#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param num int整型一维数组
# @return int整型二维数组
#
class Solution:
def permute(self , num: List[int]) -> List[List[int]]:
# write code here
n=len(num)
ans=[]
path=[]
def backtrack(path,i,nums):
if i==n:
ans.append(path.copy())
for x in nums:
path.append(x)
backtrack(path,i+1,nums-{x})
path.pop()
backtrack(path,0,set(num))
return ans



京公网安备 11010502036488号