描述:
输出全排列
代码:
1 class Solution: 2 # @param num, a list of integer 3 # @return a list of lists of integers 4 def doSth(self, num): 5 result = self.permute(num[1:]) 6 for lst in result: 7 for i in range(len(lst) + 1): 8 yield lst[:i] + num[:1] + lst[i:] 9 10 def permute(self, num): 11 if len(num) == 0: return [] 12 if len(num) == 1: return [num] 13 14 return list(self.doSth(num))
#Leet Code# Permutation
时间: 2024-10-09 10:51:09