algo
algo copied to clipboard
This code will not work properly with this input: [9, 0, 3, 5, 7]
This code will not work properly with this input: [9, 0, 3, 5, 7] Subsets_test.go https://github.com/hoanhan101/algo/blob/46d524ff83ff5fc2f4c6d2a63daa1f7b11a883ae/gtci/subsets_test.go#L47
func subsets(nums []int) [][]int {
var result [][]int
result = append(result, []int{})
for j := 0; j < len(nums); j++ {
l := len(result)
for i := 0; i < l; i++ {
var dst []int
dst = append(dst, result[i]...)
dst = append(dst, nums[j])
result = append(result, dst)
}
}
return result
}