Target Sum

Medium · Dynamic Programming · about 20 minutes

Asked at Meta, Google, Amazon.

Put either a + or a - in front of every value in nums (all non-negative), then add everything up. Count how many of the possible sign choices produce exactly target.

Related guides