Plus One @ LeetCode (Python)
Merge Intervals @ LeetCode (Python)

Permutations @ LeetCode (Python)

kitt posted @ 2014年2月19日 23:26 in LeetCode , 3612 阅读

 

class Solution:
    # @param num, a list of integer
    # @return a list of lists of integers
    def permute(self, num):
        length = len(num)
        if length == 0: return []
        if length == 1: return [num]
        res = []
        for i in xrange(length):
            for j in self.permute(num[0:i] + num[i+1:]):
                res.append([num[i]] + j)
        return res
Avatar_small
lucasqiu 说:
2014年7月20日 21:37

这种写法很巧妙阿 需要对python很熟悉


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter