You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if(curr>max || index>nums.length-1) returnfalse; // if we passed the max, or we reached the end of the array, return false
if(curr==max) returntrue; // if we reached the goal (total/2) we found a possible partition
if(results[index][curr]==1) returntrue; // if we already computed teh result for the index i with the sum current, we retrieve this result (1 for true)
if(results[index][curr]==2) returnfalse; // if we already computed teh result for the index i with the sum current, we retrieve this result (2 for false)
booleanres = isPartitionable(max, curr+nums[index], index+1, nums, results) || isPartitionable(max, curr, index+1, nums, results); // else try to find the equal partiion, taking this element, or not taking it
results[index][curr] = res ? 1 : 2; // store the result for this index and this current sum, to use it in dynamic programming