首页 > 其他 > 详细

#Leet Code# Permutation

时间:2014-08-11 17:10:32      阅读:247      评论:0      收藏:0      [点我收藏+]

描述:

输出全排列

代码:

 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,布布扣,bubuko.com

#Leet Code# Permutation

原文:http://www.cnblogs.com/mess4u/p/3904880.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!