今天的回国机票被改到明天了,请问怎么投诉 (转载)# Money - 海外理财
p*g
1 楼
what is the problem with the code?
=====
string longestPalindrome(string s) {
int len = s.size();
if (len==0 || len==1) return s;
int **maxLen = new int*[len];
int **start = new int*[len];
for (int i=0; i maxLen[i] = new int[len];
start[i] = new int[len];
}
for (int i=0; i maxLen[i][i] = 1;
start[i][i] = i;
}
for (int i=0; i maxLen[i][i+1] = (s[i]==s[i+1]? 2:1);
start[i][i+1] = i;
}
for (int l=3; l<=len; l++) {
for (int i = 0; i int ln = -1;
int st = -1;
if (s[i] == s[i+l-1] && start[i+1][i+l-2]==i+1 && maxLen[i+1
][i+l-2]==l-2 ) {
ln = 2+maxLen[i+1][i+l-2];
st = i;
} else {
if (maxLen[i][i+l-2] >= maxLen[i+1][i+l-1]) {
ln = maxLen[i][i+l-2];
st = start[i][i+l-2];
} else {
ln = maxLen[i+1][i+l-1];
st = start[i+1][i+l-1];
}
}
maxLen[i][i+l-1] = ln;
start[i][i+l-1] = st;
}
}
int stt = start[0][len-1];
int lnn = maxLen[0][len-1];
for (int i=0; i delete [] maxLen[i] ;
delete [] start[i] ;
}
delete maxLen;
delete start;
return string(s,stt, lnn);
}
=====
string longestPalindrome(string s) {
int len = s.size();
if (len==0 || len==1) return s;
int **maxLen = new int*[len];
int **start = new int*[len];
for (int i=0; i
start[i] = new int[len];
}
for (int i=0; i
start[i][i] = i;
}
for (int i=0; i
start[i][i+1] = i;
}
for (int l=3; l<=len; l++) {
for (int i = 0; i
int st = -1;
if (s[i] == s[i+l-1] && start[i+1][i+l-2]==i+1 && maxLen[i+1
][i+l-2]==l-2 ) {
ln = 2+maxLen[i+1][i+l-2];
st = i;
} else {
if (maxLen[i][i+l-2] >= maxLen[i+1][i+l-1]) {
ln = maxLen[i][i+l-2];
st = start[i][i+l-2];
} else {
ln = maxLen[i+1][i+l-1];
st = start[i+1][i+l-1];
}
}
maxLen[i][i+l-1] = ln;
start[i][i+l-1] = st;
}
}
int stt = start[0][len-1];
int lnn = maxLen[0][len-1];
for (int i=0; i
delete [] start[i] ;
}
delete maxLen;
delete start;
return string(s,stt, lnn);
}