inspired by https://discuss.leetcode.com/topic/76243/java-15-ms-c-3-ms-o-ns-iterative-dp-solution-using-subset-sum-with-explanation

```
public boolean canPartition(int[] nums) {
int sum = 0;
for (int x : nums) {
sum += x;
}
return (0 == sum % 2) && subsum(nums, sum / 2);
}
private boolean subsum(int[] nums, int s) {
int[] cnt = new int[1 + s];
cnt[0] = 1;
for (int x : nums) {
for (int sum = s; sum >= x; --sum) {
//sum: x + sum-x
cnt[sum] += cnt[sum - x];
if (cnt[s] != 0) return true;
}
}
return false;
}
```