diff --git a/Data Structure and Algorithm/DP/Equal Sum Partition.cpp b/Data Structure and Algorithm/DP/Equal Sum Partition.cpp new file mode 100644 index 0000000..c643887 --- /dev/null +++ b/Data Structure and Algorithm/DP/Equal Sum Partition.cpp @@ -0,0 +1,50 @@ +// Problem Statement: +// Given an array arr[] of size N, +// check if it can be partitioned into two parts such that the sum of elements in both parts is the same. +// OUTPUT:if the array can be partitioned into two equal sum parts print +// YES else NO + +#include +#define int long long +//AND THE SHOW BEGINS :)// +using namespace std; +int dp[60005][500]; +bool check(int current,int sum,int arr[],int n) +{ + if(n==0) return false; + if(dp[current][n-1]!=-1) return dp[current][n-1]; + else if(current+arr[n-1]==sum) return dp[current][n-1]=1; + else if(current+arr[n-1]>t; + while(t--) + { + int n;cin>>n; + int arr[n]; + for(int i=0;i>arr[i]; + int sum=0; + memset(dp,-1,sizeof(dp)); + for(int i=0;i +#define int long long +//AND THE SHOW BEGINS :)// +using namespace std; +int dp[10005][10005]; +bool check(int current, int sum, int arr[], int n) +{ + if (n == 0) + return false; + if (dp[current][n - 1] != -1) + return dp[current][n - 1]; + else if (current + arr[n - 1] == sum) + return dp[current][n - 1] = 1; + else if (current + arr[n - 1] < sum) + { + return dp[current][n - 1] = ((check(current + arr[n - 1], sum, arr, n - 1)) || (check(current, sum, arr, n - 1))); + } + else + { + return dp[current][n - 1] = check(current, sum, arr, n - 1); + } +} +signed main() +{ + int t = 1; + cin >> t; + while (t--) + { + int n, sum; + cin >> n >> sum; + int arr[n]; + for (int i = 0; i < n; i++) + cin >> arr[i]; + int current = 0; + memset(dp, -1, sizeof(dp)); + cout << check(current, sum, arr, n); + } + return 0; +} diff --git a/main.js b/main.js index f3529d3..3518b4b 100644 --- a/main.js +++ b/main.js @@ -44,17 +44,25 @@ const participants = [ "linkedIn": "https://www.linkedin.com/in/sachin-choudhary-7037381a9/", "github": "https://github.com/sachin-611", }, - { "name": "Ankit Gadhwal", + { + "name": "Ankit Gadhwal", "img": "https://avatars.githubusercontent.com/u/60103160?v=4", "year": "BE - 2023", "linkedIn": "https://www.linkedin.com/in/ankit-gadhwal-a9451b18b/", "github": "https://github.com/Ankit-123-123", - } + }, + { + "name": "Shivangi Chauhan", + "img": "https://avatars.githubusercontent.com/u/62792560?v=4", + "year": "BE - 2023", + "linkedIn": "https://www.linkedin.com/in/shivangi-chauhan-57919a191/", + "github": "https://github.com/Flaming-Phoenix24", + }, ] function loadParticipants() { participants.forEach((participant) => { - + const profileCard = `