Partition array sum with signs

Write codeMedium25 min

Your task

Given a non-negative integer array nums and an integer target, you must prepend either a '+' or a '-' to every element and concatenate them into an arithmetic expression. Return the number of distinct sign assignments whose expression evaluates to target. The array has up to 20 elements, each in [0, 1000], and the sum of all elements does not exceed 1000.

Examples

find_target_sum_ways(nums: list[int], target: int) -> int
Example 1
Inputfind_target_sum_ways([1, 1, 1, 1, 1], 3)
Output5