由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Palindrome Partitioning II Runtime Error
相关主题
Palindrome Partitioning II 的DP做法?leetcode 3sum c++解法超时
这种backtracking的问题怎么算时间复杂度?比如palindrom patitioning.请教下leetcode Permutations II
palindrome partitioning 2leetcode的online judge runtime error是指什么?
大家帮忙看看我的Palindrome II 的解法leetcode 的 Insert Interval 就是过不了大的
leetcode我这2个palindrome的为什么过不了大ojleetcode Parlindrome Partition run time error
leetcode Palindrome Partitioning请问为什么这个程序会出现RunTime Error
Leetcode Surrounded Regions Large Case Runtime Errorleetcode彻底挂了么
palindrome partioning IIpalindrome int这个recursive能再java上实现么?
相关话题的讨论汇总
话题: len话题: int话题: dp话题: pm话题: vector
进入JobHunting版参与讨论
1 (共1页)
C****y
发帖数: 77
1
Last executed input: "eegiicgaeadbcfacfhifdbiehbgejcaeggcgbahfcajfhjjdgj"
但是offline测试是通过了,研究了半天没找出来为何。
求大神指点。
Code:
class Solution {
public:
int minCut(string s) {
int len = s.length();
vector dp(len, len);
for (int i = 0; i < len; i++) {
dp[i] = i;
}
vector > pM(len, vector(len, false));
for (int l = 1; l < len + 1; l++) {
for (int i = 0; i < len; i++) {
int j = i + l -1;
pM[i][j] = (s[i] == s[j] && (j - i < 2 || pM[i+1][j-1]));
}
}

for (int i = 1; i < len; i++) {
for (int j = 0; j <= i; j++) {
if (pM[j][i]) {
if (j == 0) {
dp[i] = 0;
break;
}
if (dp[i] > dp[j-1] + 1) {
dp[i] = dp[j-1] + 1;
}
}
}
}
return dp[len-1];
}
};
1 (共1页)
进入JobHunting版参与讨论
相关主题
palindrome int这个recursive能再java上实现么?leetcode我这2个palindrome的为什么过不了大oj
请教一个Palindrome Partition问题leetcode Palindrome Partitioning
leetcode里的Palindrome partition问题Leetcode Surrounded Regions Large Case Runtime Error
请教一下palindrome partitioning用memoization的问题palindrome partioning II
Palindrome Partitioning II 的DP做法?leetcode 3sum c++解法超时
这种backtracking的问题怎么算时间复杂度?比如palindrom patitioning.请教下leetcode Permutations II
palindrome partitioning 2leetcode的online judge runtime error是指什么?
大家帮忙看看我的Palindrome II 的解法leetcode 的 Insert Interval 就是过不了大的
相关话题的讨论汇总
话题: len话题: int话题: dp话题: pm话题: vector