132. Palindrome Partitioning II
来源:互联网 发布:免费淘宝号和密码大全 编辑:程序博客网 时间:2024/05/22 14:12
class Solution {private: vector<vector<string>> result; vector<string> curlist; bool judge(string &s,int start,int end) { if(end==start) return true; while(end>start) { if(s[end]!=s[start]) return false; end--; start++; } return true; } void dfs(string &s,int start) { if(curlist.size()>0&&start>=s.size()) { vector<string> r(curlist); result.push_back(r); } for(int i=start;i<s.size();i++) { if(judge(s,start,i)) { curlist.push_back(s.substr(start,i-start+1)); dfs(s,i+1); curlist.pop_back(); } } }public: vector<vector<string>> partition(string s) { dfs(s,0); return result; }};
0 0
- 132. Palindrome Partitioning II
- 132. Palindrome Partitioning II
- 132. Palindrome Partitioning II
- 132. Palindrome Partitioning II
- 132. Palindrome Partitioning II
- 132. Palindrome Partitioning II
- 132. Palindrome Partitioning II
- 132. Palindrome Partitioning II
- 132. Palindrome Partitioning II
- 132. Palindrome Partitioning II
- 132. Palindrome Partitioning II
- 132. Palindrome Partitioning II
- 132. Palindrome Partitioning II
- 132. Palindrome Partitioning II
- 132. Palindrome Partitioning II
- 131. Palindrome Partitioning && 132. Palindrome Partitioning II
- LeetCode 132. Palindrome Partitioning II
- [LeetCode]132.Palindrome Partitioning II
- 定位
- 杭电1010Tempter of the Bone(dfs 奇偶剪枝)
- moon game(凸四边形)
- 拥抱JPA规范(转载)
- shiro-realm认证
- 132. Palindrome Partitioning II
- AsyncTask_HttpURLConnection_一键退出案例
- POJ-2624 4th Point(计算几何)
- 八、组合模式Composite(结构型)
- Codeforces 115A Party
- 打字
- Unbuntu下安装jdk
- 看了简书的感想
- listview多条目展示