Palindrome Partitioning II☆
来源:互联网 发布:linux mount nas 编辑:程序博客网 时间:2024/06/17 13:45
Given a string s, partition s such that every substring of the partition is a palindrome.
Return the minimum cuts needed for a palindrome partitioning of s.
For example, given s = "aab"
,
Return 1
since the palindrome partitioning ["aa","b"]
could be produced using 1 cut.
int minCut(string s) { int len = s.size();int* dp = new int[len+1];for(int i=len; i>=0; i--)dp[i] = len-i;bool** matrix = new bool*[len];for(int i=0; i<len; i++){matrix[i] = new bool[len];memset(matrix[i], false, sizeof(bool)*len);}for(int i=len-1; i>=0; i--)for(int j=i; j<len; j++){if(s[i] == s[j] && (j-i<2 || matrix[i+1][j-1])){matrix[i][j] = true;dp[i] = min(dp[i], dp[j+1]+1);}}return dp[0]-1; }
0 0
- Palindrome Partitioning II☆
- LeetCode : Palindrome Partitioning II
- [leetcode] Palindrome Partitioning II
- leetcode:Palindrome Partitioning II
- Palindrome Partitioning II
- 【leetcode】Palindrome Partitioning II
- Palindrome Partitioning II
- leetcode - Palindrome Partitioning II
- Palindrome Partitioning II
- Palindrome Partitioning II
- [LeetCode]Palindrome Partitioning II
- [Leetcode]Palindrome Partitioning II
- [leetcode]Palindrome Partitioning II
- Palindrome Partitioning II
- leetcode Palindrome Partitioning II
- Palindrome Partitioning II
- LetCode:Palindrome Partitioning II
- LeetCode-Palindrome Partitioning II
- linux服务器apache环境下中文乱码的解决方案
- 用一段非常难懂的语句,但是很简洁的实现了一个很实用的函数。
- 用私有API得到iOS系统里安装的所有APP
- Linux scp命令的应用
- 画个月食css
- Palindrome Partitioning II☆
- 相关参数--与GrounTruth对应关系
- 积分奖励成为app用户增长的主流渠道
- JVM调优总结 -Xms -Xmx -Xmn -Xss
- Bootstrap学习笔记(实习第2天)
- 使用Java VisualVM监控远程JVM
- 移动端Web系列3 -- viewport
- android的logcat详细用法
- 移动端Web系列4 -- meta