N7连不上电脑# PDA - 掌中宝
z*8
1 楼
int C = 0, R = 0;
for (int i = 1; i < n-1; i++) {
int i_mirror = 2*C-i; // equals to i' = C - (i-C)
P[i] = (R > i) ? min(R-i, P[i_mirror]) : 0;
第一个iteration的时候 i_mirror = -1, 这时候P[i_mirror]直接抛错了?
原文: http://leetcode.com/2011/11/longest-palindromic-substring-part-ii.html
for (int i = 1; i < n-1; i++) {
int i_mirror = 2*C-i; // equals to i' = C - (i-C)
P[i] = (R > i) ? min(R-i, P[i_mirror]) : 0;
第一个iteration的时候 i_mirror = -1, 这时候P[i_mirror]直接抛错了?
原文: http://leetcode.com/2011/11/longest-palindromic-substring-part-ii.html