https://programmers.co.kr/learn/courses/30/lessons/43165
Code
1
2
3
4
5
from itertools import product
def solution(numbers, target):
numbers = [(n, -n) for n in numbers]
return len([ns for ns in product(*numbers) if sum(ns) == target])
Complexity
$O(2^n)$
- $n$ =
|numbers|
PREVIOUSEtc