char *path
char **res
回文串分割
树形结构图
树形结构
叶子结点表示完结
bt(s,startindex)
{
//切割到最后一个 startindex 是切割线
if(startindex >=s.size)
{
//for里判断
path.push
return;
}
for()
{
//子串[startindex,i]
panduan(s,i,index)//是回文
path.push(子串)
else continue;
}
bt(s,i+1)
path.pop
}
给你一个字符串 s,请你将 s 分割成一些子串,使每个子串都是 回文串 。返回 s 所有可能的分割方案。
回文串 是正着读和反着读都一样的字符串。
示例 1:
输入:s = "aab"
输出:[["a","a","b"],["aa","b"]]
示例 2:
输入:s = "a"
输出:[["a"]]
提示:
1 <= s.length <= 16
s 仅由小写英文字母组成
来源:力扣(LeetCode)
链接:https://leetcode.cn/problems/palindrome-partitioning
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
/**
* Return an array of arrays of size *returnSize.
* The sizes of the arrays are returned as *returnColumnSizes array.
* Note: Both returned array and *columnSizes array must be malloced, assume caller calls free().
*/
char **path;//
int pathTop;
char ***res;//划分后是回文的集合数组个数][集合内字符串个数][字符串内部]
int resTop;
int *length;
int judge(char *s,int begin,int end)
{
int flag=1;
while(end >= begin)