Given a list of unique integers numbers
and an integer target
, find the number of different combinations of elements from numbers
that sum up to target.
numbers: number[]
: An array of integerstarget: number
: An integerInput: numbers = [1,2,3], target = 4Output: 7Explanation: The possible combinations are: (1, 1, 1, 1), (1, 1, 2), (1, 2, 1), (1, 3), (2, 1, 1), (2, 2), (3, 1)
Input: numbers = [7], target = 2Output: 0Explanation: There is no combination of elements in [7] that can add up to 2.
Input: numbers = [2,4], target = 6Output: 3Explanation: The possible combinations are: (2, 2, 2), (2, 4), (4, 2)
numbers.length
<= 200numbers[i]
<= 1000target
<= 1000Given a list of unique integers numbers
and an integer target
, find the number of different combinations of elements from numbers
that sum up to target.
numbers: number[]
: An array of integerstarget: number
: An integerInput: numbers = [1,2,3], target = 4Output: 7Explanation: The possible combinations are: (1, 1, 1, 1), (1, 1, 2), (1, 2, 1), (1, 3), (2, 1, 1), (2, 2), (3, 1)
Input: numbers = [7], target = 2Output: 0Explanation: There is no combination of elements in [7] that can add up to 2.
Input: numbers = [2,4], target = 6Output: 3Explanation: The possible combinations are: (2, 2, 2), (2, 4), (4, 2)
numbers.length
<= 200numbers[i]
<= 1000target
<= 1000console.log()
aparecerão aqui.