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

京公网安备 11010502036488号