<p>Given a string <code>s</code>, return <code>true</code> <em>if it is possible to split the string</em> <code>s</code> <em>into three <strong>non-empty</strong> palindromic substrings. Otherwise, return </em><code>false</code>.​​​​​</p>

<p>A string is said to be palindrome if it the same string when reversed.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;abcbdd&quot;
<strong>Output:</strong> true
<strong>Explanation: </strong>&quot;abcbdd&quot; = &quot;a&quot; + &quot;bcb&quot; + &quot;dd&quot;, and all three substrings are palindromes.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;bcbddxy&quot;
<strong>Output:</strong> false
<strong>Explanation: </strong>s cannot be split into 3 palindromes.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>3 &lt;= s.length &lt;= 2000</code></li>
	<li><code>s</code>​​​​​​ consists only of lowercase English letters.</li>
</ul>

int is_palindromic(string& s, int i, int j, int** is_parlind){
    if (j==i+1){
        is_parlind[i][j]=1;
        return 1;
    }else if (j==i+2){
        if (s[i]==s[j-1]){
             is_parlind[i][j]=1;
             return 1;
        }else{
            is_parlind[i][j]=0;
            return 0;
        }
    }
    if (is_parlind[i][j]==-1){
        if (s[i]!=s[j-1]){
            is_parlind[i][j]=0;
        }else{
            is_parlind[i][j] = is_palindromic(s, i+1, j-1, is_parlind);
        }
    }
    return is_parlind[i][j];
}
class Solution {
public:
    bool checkPartitioning(string s) {
        int **is_parlind = new int*[s.size()];
        for (int i = 0;i<s.size();i++){
            is_parlind[i] = new int[s.size()+1];
            fill_n(is_parlind[i],s.size()+1,-1);
        }
//        if (is_palindromic(s,0,s.size(),is_parlind)==1) return true;
        for (int i = 1;i<s.size();i++){
            // cout<<i<<endl;
            // if (is_palindromic(s,0,i,is_parlind)==1 && is_palindromic(s,i,s.size(),is_parlind)==1) return true;
            if (is_palindromic(s,0,i,is_parlind)==1){
                for (int j = i+1;j<s.size();j++){
 //                   cout<<i<<" "<<j<<" "<<is_palindromic(s,1,3,is_parlind)<<endl;
                    if (is_palindromic(s,i,j,is_parlind)==1 && is_palindromic(s,j,s.size(),is_parlind)==1) return true;
                }
            }
        }
        return false;
    }
};
85803