判断一个字符串是否为回文串最简单的方法是从两边向中间收缩看是否字符相同。
1 bool is_pali(int l, int r) 2 { 3 while(l < r) 4 { 5 if(str[l] != str[r]) return false; 6 ++l; --r; 7 } 8 return true; 9 }