【LeetCode】Palindrome Partitioning II
2014-12-05 11:57
375 查看
class Solution { public: int minCut(string s) { const int n = s.size(); vector<int> f(n+1); //bool p ; vector<vector<bool>> p(n, vector<bool>(n,false)); for (int i = 0; i <= n; i++) { f[i] = n - 1 - i; } for (int i = n - 1; i >= 0; i--) { for (int j = i; j < n; j++) { if (s[i] == s[j] && ((j - i < 2) || p[i + 1][j - 1])) { p[i][j] = true; f[i] = min(f[i], f[j + 1] + 1); } } } return f[0]; } };
相关文章推荐
- leetcode - Palindrome Partitioning II
- LeetCode_Palindrome Partitioning II
- LeetCode: Palindrome Partitioning II [132]
- 【LeetCode】Palindrome Partitioning II
- leetcode:Palindrome Partitioning II
- Leetcode_palindrome-partitioning-ii
- Leetcode:Palindrome Partitioning II
- leetcode[132]Palindrome Partitioning II
- LeetCode 132. Palindrome Partitioning II(回文切分)
- Palindrome Partitioning I,II[leetcode] DFS以及DP的解法
- 132 Palindrome Partitioning II [Leetcode]
- LeetCode:palindrome-partitioning-ii
- LeetCode 132. Palindrome Partitioning II
- leetCode解题报告之Palindrome Partitioning I,II(DFS,DP)
- [leetcode 132] Palindrome Partitioning II
- leetcode 日经贴,Cpp code -Palindrome Partitioning II
- 【LeetCode】Palindrome Partitioning I&II
- [leetcode]Palindrome Partitioning II
- Leetcode: Palindrome Partitioning II
- [LeetCode] Palindrome Partitioning II