From bd3089831bd5ce1d2100e7ea16b4a95c7009a04c Mon Sep 17 00:00:00 2001 From: chayan das <110921638+Chayandas07@users.noreply.github.com> Date: Wed, 22 May 2024 22:31:33 +0530 Subject: [PATCH] Create 131. Palindrome Partitioning1 --- 131. Palindrome Partitioning1 | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 131. Palindrome Partitioning1 diff --git a/131. Palindrome Partitioning1 b/131. Palindrome Partitioning1 new file mode 100644 index 0000000..b645475 --- /dev/null +++ b/131. Palindrome Partitioning1 @@ -0,0 +1,38 @@ +class Solution { +public: + + bool ispalindrome(string s,int start,int last){ + while(start<=last){ + if(s[start++]!=s[last--]){ + return false; + } + + } + return true; + } + + void solve(vector> &ans,string s,vector &path,int idx,int n){ + + if(idx==n){ + ans.push_back(path); + return; + } + + for(int i=idx;i> partition(string s) { + vector> ans; + vector path; + int n = s.size(); + solve(ans,s,path,0,n); + return ans; + } +};