 All Problems
Target Sum
medium
dynamic programming
arrays
backtracking
amazon
facebook
google

Given an integer array nums and an integer target, assign '+' or '-' to each element and return the count of ways to reach the target sum.

Example 1:

Input: 1 1 1 1 1
Target: 3
Output: 5

Example 2:

Input: 1
Target: 1
Output: 1

Input format: Line 1: space-separated array. Line 2: target.

Output format: Number of ways.

Run to check your code against the sample cases, or submit to run every case