public:
bool judge(string str) {
int left = 0; //⾸
int right = str.length() - 1; //尾
while(left < right){ //⾸尾往中间靠
if(str[left] != str[right]) //⽐较前后是否相同
return false;
left++;
right--;
}
return true;
}
};
public:
bool judge(string str) {
int left = 0; //⾸
int right = str.length() - 1; //尾
while(left < right){ //⾸尾往中间靠
if(str[left] != str[right]) //⽐较前后是否相同
return false;
left++;
right--;
}
return true;
}
};