We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
出处 LeetCode 算法第131题 给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串。 返回 s 所有可能的分割方案。 示例: 输入: "aab" 输出: [ ["aa","b"], ["a","a","b"] ]
出处 LeetCode 算法第131题
给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串。
返回 s 所有可能的分割方案。
示例:
输入: "aab" 输出: [ ["aa","b"], ["a","a","b"] ]
采用DFS的方式解答
function copy(array) { var res = []; var length = array.length; for (var i = 0; i < length; i ) { res.push(array[i]); } return res; } function DFS(res, temp, s) { if (!s) { res.push(copy(temp)); return; } for (var i = 1; i <= s.length; i ) { var current = s.slice(0, i); if (current.split('').reverse().join('') == current) { temp.push(current); DFS(res, temp, s.slice(i)); temp.pop(); } } } var partition = function (s) { var res = []; var temp = []; DFS(res, temp, s); return res; };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
习题
思路
采用DFS的方式解答
习题
The text was updated successfully, but these errors were encountered: