Thanks to sharing: https://discuss.leetcode.com/topic/62334/simple-c-4-line-solution-using-a-bitset/4

```
import java.math.BigInteger;
public class Solution {
public boolean canPartition(int[] nums) {
int total = 0;
for (int num : nums) {
total += num;
}
if (total % 2 != 0) return false;
BigInteger state = new BigInteger("1");
for (int num : nums){
state = state.or(state.shiftLeft(num));
}
return state.testBit(total / 2);
}
}
```