Here is the code and error message in PyCharm. If anyone have any insights what is wrong with the syntax, it will be great. :)
candidates
is an array of non-negative integers, and target
is a positive integer. For example, candidates
are [10,1,2,7,6,1,5]
and target
is 10
.
I am using Python 2.6 on OSX.
def combinationSum2(self, candidates, target):
candidates.sort()
table = [None] + [set() for i in range(target)]
for i in candidates:
if i > target:
break
for j in range(target - i, 0, -1):
table[i + j] |= {elt + (i,) for elt in table[j]}
table[i].add((i,))
return map(list, table[target])