Given an array of positive integers and a difference d, return the number of ways to partition the array into two subsets such that the difference of their sums equals d. This is a classic counting transformation from partition DP to subset-sum counting.
nums = array of non-negative integers, d = required difference
number of valid partitions
Example 1:
Input:
nums = [1,1,2,3] d = 1
Output:
3
Explanation:
There are 3 partitions whose subset sums differ by 1.
Example 2:
Input:
nums = [1,2,7,1] d = 9
Output:
2
Explanation:
The target subset-sum reduction yields 2 valid subsets.