From c639ac38ffe7dbe98eff1141dd1297aec366b631 Mon Sep 17 00:00:00 2001 From: Utkarsh Jaulkar <84310520+utkarshjaulkar@users.noreply.github.com> Date: Fri, 28 Oct 2022 17:39:08 +0530 Subject: [PATCH 1/2] Created Make_Pallindrome.cpp file --- C++/Make_Pallindrome.cpp | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 C++/Make_Pallindrome.cpp diff --git a/C++/Make_Pallindrome.cpp b/C++/Make_Pallindrome.cpp new file mode 100644 index 0000000..1ab52fd --- /dev/null +++ b/C++/Make_Pallindrome.cpp @@ -0,0 +1,68 @@ +// Github username: utkarshjaulkar +// Aim: This is a C++ Program that Solves Make Palindrome Problem using Dynamic Programming technique. +// Date: 28/10/2022 + +// start coding +#include +#include +#include + +using namespace std; + +int longestCommonSubsequece(string str1, string str2) +{ + int len1=str1.length(), len2=str2.length(); + int i, j; + + //create a matrix of order (len1+1)*(len2+1) to tabulate values + int LCS[len1+1][len2+1]; + + //LCS[i][j]=Length of longest common subsequence of str1[0....(i-1)] and str2[0...(j-1)] + + //initializing + for(i=0;i<=len1;i++) + LCS[i][0]=0; //empty str2 + + for(j=0;j<=len2;j++) + LCS[0][j]=0; //empty str1 + + //now, start filling the matrix row wise + for(i=1;i<=len1;i++) + { + for(j=1;j<=len2;j++) + { + //if current character of both strings match + if(str1[i-1]==str2[j-1]) + { + LCS[i][j]=1+LCS[i-1][j-1]; + } + + //mismatch + else + { + LCS[i][j]=max(LCS[i-1][j],LCS[i][j-1]); + } + } + } + + //now, return the final value + return LCS[len1][len2]; + +} + +int main() +{ + string str1; + + cout<<"Enter the string - "; + getline(cin,str1); + + string str2=str1; + reverse(str2.begin(),str2.end()); + + cout<<"Minimum number of characters to be inserted in the input string to make it a palindrome is "< Date: Fri, 28 Oct 2022 17:41:15 +0530 Subject: [PATCH 2/2] Updated Contibutors.md --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 1ec1014..a2e8e00 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -39,6 +39,7 @@ Check bellow code as referance. | Arn Arn | arn355 | Mail | | Sarthak Roy | sarthakroy2002 | Mail | | Niels Mijnster | nielsmijnster | Mail | +| Utkarsh Jaulkar | utkarshjaulkar | Mail |

🖥️ Happy Hacking...