From 3973bf8462cdcc36f51a9aec051f2705c0aaf4dd Mon Sep 17 00:00:00 2001 From: Mickey_413 <43994883+ultimatecoder2@users.noreply.github.com> Date: Fri, 2 Oct 2020 08:26:52 +0530 Subject: [PATCH] Equal Subset Problem Added solution of equal Subset Problem --- Problems and General Algos/EqualSubset.cpp | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Problems and General Algos/EqualSubset.cpp diff --git a/Problems and General Algos/EqualSubset.cpp b/Problems and General Algos/EqualSubset.cpp new file mode 100644 index 0000000..8b690ac --- /dev/null +++ b/Problems and General Algos/EqualSubset.cpp @@ -0,0 +1,50 @@ +/* +Problem: To check if an array can be divided into two subarrays of equal sum +*/ + +#include +using namespace std; +bool canPartition(vector& nums) { + int sum = 0; + for(int i=0;i>n; + vectorvec(n); + for(int i=0;i>vec[i]; + if(canPartition(nums)) + cout<<"This array can be divided into 2 subarrays of equal sum"<