元のタイトル
コードの実装(最初のブラシの自己解決)
class Solution {
public:
bool checkPartitioning(string s) {
int strl = s.size(),end,start;
vector<vector<int>> dp(strl,vector<int>(strl,0));
for(end = 0;end<strl;end++)
{
for(start=end;start>=0;start--)
{
if(s[start] == s[end])
{
if(end <= start+2 || dp[start+1][end-1])
dp[start][end] = 1;
}
}
}
for(start=0;start<=strl-3;start++)
{
for(end=start+1;end<=strl-2;end++)
{
if(dp[0][start] && dp[start+1][end] && dp[end+1][strl-1])
return true;
}
}
return false;
}
};