From 021efe997b277e99757f2b43de7da5da7ba1126c Mon Sep 17 00:00:00 2001 From: mayanjain <85707839+mayanjain@users.noreply.github.com> Date: Fri, 1 Oct 2021 23:09:14 +0530 Subject: [PATCH 1/3] Create 1143.cpp Longest Common Subsequence solution --- C++/1143.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 C++/1143.cpp diff --git a/C++/1143.cpp b/C++/1143.cpp new file mode 100644 index 0000000..0ff3c38 --- /dev/null +++ b/C++/1143.cpp @@ -0,0 +1,27 @@ +class Solution { +public: + int longestCommonSubsequence(string t, string s) { + int tn=t.size(),sn=s.size(); + if(tn>sn){ + swap(tn,sn); + swap(t,s); + } + vector v(tn+1); + auto x=v; + int ans=0; + for(int i=0 ; i Date: Fri, 22 Oct 2021 22:25:52 +0530 Subject: [PATCH 2/3] create nextpermutation.cpp 1 c++ solution added --- C++/nextpermutation.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 C++/nextpermutation.cpp diff --git a/C++/nextpermutation.cpp b/C++/nextpermutation.cpp new file mode 100644 index 0000000..29818e6 --- /dev/null +++ b/C++/nextpermutation.cpp @@ -0,0 +1,33 @@ +class Solution { +public: + void nextPermutation(vector &num) { + // Start typing your C/C++ solution below + // DO NOT write int main() function + int sz = num.size(); + int k=-1; + int l; + //step1 + for (int i=0;inum[k]){ + l=i; + } + } + //step3 + int tmp = num[l]; + num[l]=num[k]; + num[k]=tmp; + //step4 + reverse(num.begin()+k+1,num.end()); + } +}; From 39213653d26f7afa97740642e7f2061555492770 Mon Sep 17 00:00:00 2001 From: DiptanshuG <78592980+DiptanshuG@users.noreply.github.com> Date: Sat, 23 Oct 2021 01:51:31 +0530 Subject: [PATCH 3/3] create stringstream.cpp added 1 solution --- C++/stringstream.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 C++/stringstream.cpp diff --git a/C++/stringstream.cpp b/C++/stringstream.cpp new file mode 100644 index 0000000..ed97696 --- /dev/null +++ b/C++/stringstream.cpp @@ -0,0 +1,34 @@ +#include +#include +#include +using namespace std; + +vector parseInts(string str) +{ + // Complete this function + stringstream ss(str); + vector result; + char ch; + int tmp; + + while (ss >> tmp) + { + result.push_back(tmp); + ss >> ch; + } + + return result; +} + +int main() +{ + string str; + cin >> str; + vector integers = parseInts(str); + for(int i = 0; i < integers.size(); i++) + { + cout << integers[i] << "\n"; + } + + return 0; +}