最近刷leetcode时发现了一个比较好的学习方法,
accept后,可以查看其他人的代码,对比自己的,可以学到很多精妙的思路。
例如,这道题目,求出一个列表的所有子列表:
If nums = [1,2,3],asolution
is:
[
[3],
[1],
[2],
[1,2,3],
[1,3],
[2,3],
[1,2],
[]
]
我是用组合来写的:
importitertools
classSolution(object):
defsubsets(self,nums):
"""
:typen