From 4d8ef93945f151d707167406fe6f79458f2f08cb Mon Sep 17 00:00:00 2001 From: i-vishi Date: Tue, 2 Oct 2018 15:15:14 +0530 Subject: [PATCH 1/2] Update Subset-Sum.cpp --- Dynamic Programming/Subset-Sum.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dynamic Programming/Subset-Sum.cpp b/Dynamic Programming/Subset-Sum.cpp index 12974fb09..1896cd216 100644 --- a/Dynamic Programming/Subset-Sum.cpp +++ b/Dynamic Programming/Subset-Sum.cpp @@ -3,7 +3,9 @@ #include using namespace std; + // Returns true if there is a subset of set[] with sun equal to given sum + bool isSubsetSum(int set[], int n, int sum){ bool subset[n+1][sum+1]; for (int i = 0; i <= n; i++) @@ -24,7 +26,7 @@ bool isSubsetSum(int set[], int n, int sum){ int main() { int n,sum; - //input n - size of set and sum + //input n - size of set and sum to which it has to be compared cin>>n>>sum; int set[n]; //input elements of set From a15eec55146f71781682d34dc85d8ca40d197097 Mon Sep 17 00:00:00 2001 From: i-vishi Date: Tue, 2 Oct 2018 15:17:54 +0530 Subject: [PATCH 2/2] Update and rename Mathematics/CommonSubSeq.cpp to Dynamic Programming/CommonSubSeq.cpp --- {Mathematics => Dynamic Programming}/CommonSubSeq.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename {Mathematics => Dynamic Programming}/CommonSubSeq.cpp (86%) diff --git a/Mathematics/CommonSubSeq.cpp b/Dynamic Programming/CommonSubSeq.cpp similarity index 86% rename from Mathematics/CommonSubSeq.cpp rename to Dynamic Programming/CommonSubSeq.cpp index 437dd8135..0e5ba627f 100644 --- a/Mathematics/CommonSubSeq.cpp +++ b/Dynamic Programming/CommonSubSeq.cpp @@ -1,8 +1,6 @@ -/* Implementation of LCS problem using DP*/ -#include -#include -#include +/* Implementation of LCS problem using Dynamic Programming*/ +#include using namespace std; @@ -36,11 +34,13 @@ void lcs(string X, string Y){ else j--; } + //output cout << "LCS of " << X << " and " << Y << " is " << lcs; } int main(){ string a,b; + //input two strings cin>>a; cin>>b; lcs(a,b);