Problems / Target Sum
Medium

Target Sum

Medium 46 submissions 25 coins +100 XP
Backtracking Dynamic Programming
Problem Description
Put a `+` or `-` sign in front of every number in `nums` and add them all up. Return how many sign assignments produce `target`. **Example 1:** ``` Input: nums = [1, 1, 1, 1, 1], target = 3 Output: 5 ``` **Example 2:** ``` Input: nums = [1], target = 1 Output: 1 ``` **Example 3:** ``` Input: nums = [2, 3], target = 0 Output: 0 ```
Constraints
- `1 <= nums.length <= 20` - `0 <= nums[i] <= 1000` - `-1000 <= target <= 1000`

Need help?

Connect with expert programmers for real-time collaborative coding, video meetings, and whiteboard sessions via CodeConnect.

Video Call Whiteboard Live Coding Screen Share