Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated #57

Merged
merged 3 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

/* Implementation of LCS problem using DP*/
#include<iostream>
#include<cstring>
#include<cstdlib>
/* Implementation of LCS problem using Dynamic Programming*/
#include <bits/stdc++.h>

using namespace std;

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion Dynamic Programming/Subset-Sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#include <bits/stdc++.h>

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++)
Expand All @@ -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
Expand Down