Given an array of non-negative integers and a target, assign either a + or a - sign to each number and count how many ways the resulting expression evaluates to the target.
nums = [1,1,1,1,1], target = 35Solve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →The same DP idea as 1-D, but the state depends on two indices — often two positions in a grid, or a position in each of two sequences being compared.
Read the full 2-D Dynamic Programming guide →
Original problem on LeetCode ↗