Partition Equal Subset Sum

It beats 70.56% of all the submissions.

class Solution {  
public:  
    bool canPartition(vector<int>& nums) {
        int sum = 0;
        for(int i = 0; i < nums.size(); i++) {
            sum += nums[i];
        }

        if(sum & 1) {
            return false;
        } else {
            sum >>= 1;
            bool *dp = new bool[sum + 1]();
            dp[0] = true;

            for(int i = 0; i < nums.size(); i++) {
                for(int j = sum; j >= 0; j--) {
                    if(j + nums[i] <= sum && dp[j]) {
                        dp[j + nums[i]] = true;
                    }
                }
            }

            return dp[sum];
        }
    }
};