<p>Given a string <code>s</code>, partition <code>s</code> such that every <span data-keyword="substring-nonempty">substring</span> of the partition is a <span data-keyword="palindrome-string"><strong>palindrome</strong></span>. Return <em>all possible palindrome partitioning of </em><code>s</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> s = "aab"
<strong>Output:</strong> [["a","a","b"],["aa","b"]]
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> s = "a"
<strong>Output:</strong> [["a"]]
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s.length &lt;= 16</code></li>
	<li><code>s</code> contains only lowercase English letters.</li>
</ul>

class Solution {
public:
    vector<vector<string>>ans;
    string temp;int n;
    bool is_palindrome(string s){
        int n=(int)s.size();
        int i=0;
        int j=n-1;
        while(j>=i){
            if(s[i]==s[j]){
                i++;--j;
            }
            else return 0;
        }
         return 1;
    }
    void solve(int ind,vector<string>s){
     if(ind==n){
        ans.push_back(s);
        return;
     }

     string s1;
     for(int i=ind;i<n;i++){
        s1+=temp[i];
        if(is_palindrome(s1)){
            vector<string>s2=s;
            s2.push_back(s1);
            solve(i+1,s2);
            
        }
     }
    }
    vector<vector<string>> partition(string s) {
        n=(int)s.size();
        temp=s;
        vector<string>p={};
        solve(0,p);
        return ans;
    }
};
238095