描述:
输出全排列
代码:
class Solution:
# @param num, a list of integer
# @return a list of lists of integers
def doSth(self, num):
result = self.permute(num[1:])
for lst in result:
for i in range(len(lst) + 1):
yield lst[:i] + num[:1] + lst[i:] def permute(self, num):
if len(num) == 0: return []
if len(num) == 1: return [num] return list(self.doSth(num))