// A code block
func subsets(nums []int) [][]int {
result := [][]int{}
result = append(result, []int{}) for i:= 0; i < len(nums) ; i ++ {
newSets := [][]int{}
for _,set := range result {
setCopy := make([]int, len(set))
copy(setCopy, set)
setCopy = append(setCopy, nums[i])
newSets = append(newSets, setCopy)
} result = append(result, newSets...) }
return result
}
第九周作业1
最新推荐文章于 2023-05-06 23:20:10 发布