[LeetCode] Palindrome Partitioning
来源:互联网 发布:淘宝鱼塘是什么意思 编辑:程序博客网 时间:2024/04/30 22:26
Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s.
For example, given s = "aab"
,
Return
[ ["aa","b"], ["a","a","b"] ]
class Solution {public: vector<vector<string> >res; vector<string>v; vector<vector<string>> partition(string s) { dfs(s); return res; } void dfs(string s){ if(s.size() < 1){ res.push_back(v); return; } for(int i = 0;i < s.size();i ++){ int beg = 0,end = i; while(beg < end){ if(s[beg] == s[end]){ beg ++; end --; } else break; } if(beg >= end){ v.push_back(s.substr(0,i + 1)); dfs(s.substr(i+1)); v.pop_back(); } } }};
0 0
- 【leetcode】Palindrome Partitioning && Palindrome Partitioning II
- [LeetCode] Palindrome Partitioning && Palindrome Partitioning II
- LeetCode Palindrome Partitioning I&&Palindrome Partitioning II
- LeetCode Palindrome Partitioning, Palindrome Partitioning II
- [Leetcode][python]Palindrome Partitioning/Palindrome Partitioning II
- Leetcode:Palindrome Partitioning & Palindrome Partitioning II
- LeetCode: Palindrome Partitioning
- LeetCode : Palindrome Partitioning II
- [leetcode] Palindrome Partitioning II
- leetcode 122: Palindrome Partitioning
- leetcode:Palindrome Partitioning II
- leetcode:Palindrome Partitioning
- 【leetcode】Palindrome Partitioning
- 【leetcode】Palindrome Partitioning II
- leetcode - Palindrome Partitioning II
- Leetcode - Palindrome Partitioning
- LeetCode之Palindrome Partitioning
- [LeetCode]Palindrome Partitioning
- PHP empty(),isset()与is_null()的实例测试
- ubuntu各文件目录作用以及启动流程
- pixel clock
- 使用internal(com.android.internal)和hidden(@hide)APIs – Part 1
- 08主界面布局的实现和点击事件的添加
- [LeetCode] Palindrome Partitioning
- 虚拟字符设备的完整制作过程 模块源代码,应用,编译所有步骤均有详细介绍
- 使用internal(com.android.internal)和hidden(@hide)APIs – Part 2
- onselectstart与onselect—禁止选择或禁止复制
- poj 1338 ugly number
- Zookeeper概述(译)
- 使用internal(com.android.internal)和hidden(@hide)APIs – Part 3
- 使用internal(com.android.internal)和hidden(@hide)APIs – Part 4
- Wireshark的过滤规则