<p>Given an integer array <code>nums</code>, return <code>true</code> <em>if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or </em><code>false</code><em> otherwise</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,5,11,5]
<strong>Output:</strong> true
<strong>Explanation:</strong> The array can be partitioned as [1, 5, 5] and [11].
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,2,3,5]
<strong>Output:</strong> false
<strong>Explanation:</strong> The array cannot be partitioned into equal sum subsets.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length &lt;= 200</code></li>
	<li><code>1 &lt;= nums[i] &lt;= 100</code></li>
</ul>

class Solution {
public:
    bool solveByTabu(vector<int>& nums, int target){
        int n = nums.size();
        vector<vector<int>>dp(n+50, vector<int>(target+100,0));

        for(int row=0; row<= nums.size(); row++){
            dp[row][target]=1;
        }
       
        for(int index= n-1; index>=0; --index){
            for(int sum=target; sum>=0; --sum){
                bool include=0;
                if(sum + nums[index] <= target)
                     include = dp[index+1][sum + nums[index]];
                bool exclude = dp[index+1][sum];
                dp[index][sum] =  include || exclude;
            }
        }
        return dp[0][0];
    }
    bool canPartition(vector<int>& nums) {
        int n= nums.size();
        int index=0;
        int totalsum= 0;
        for(int i=0; i<nums.size(); i++){
            totalsum += nums[i];
        }
        if(totalsum & 1) return false;

        int target = totalsum/2;
        int currSum=0;
        // vector<vector<int>>dp(n+1, vector<int>(target+1,-1));
        return solveByTabu(nums,target);
    }
};
139536