Target Sum
Medium

Problem Statement

Assign + or - signs to array elements such that the expression sums to target value. Count number of such ways.

Examples

1Example 1
Input:
{ "nums": [ 1, 1, 1, 1, 1 ], "target": 3 }
Output:
5
2Example 2
Input:
{ "nums": [ 1, 2, 3, 4, 5 ], "target": 3 }
Output:
3
3Example 3
Input:
{ "nums": [ 1 ], "target": 1 }
Output:
1
Loading...

Sign in to Run Code and Submit