classSolution{public:boolisPalindrome(string s){
string newStr ="";for(int fast =0; fast < s.size(); fast++){if(isalnum(s[fast]))){
newStr +=tolower(s[fast]);}}for(int front =0,rear = newStr.size()-1; front < newStr.size()/2; front++,rear--){if(newStr[front]!= newStr[rear]){returnfalse;}}returntrue;}};
classSolution{public:boolisPalindrome(string s){
string newStr ="";for(char ch : s){if(isalnum(ch)){
newStr +=tolower(ch);}}int n = newStr.size();int left =0, right = n -1;while(left < right){if(newStr[left]!= newStr[right]){returnfalse;}++left;--right;}returntrue;}};
方法三
classSolution{public:boolisPalindrome(string s){int n = s.size();int left =0, right = n -1;while(left < right){while(left < right &&!isalnum(s[left])){++left;}while(left < right &&!isalnum(s[right])){--right;}if(left < right){if(tolower(s[left])!=tolower(s[right])){returnfalse;}++left;--right;}}returntrue;}};
文章目录 一、测试效果展示二、相关链接三、优点总结四、SAA vs SAA4.1 SAA4.2 SAA 五、SAA结构5.1 专家领域知识(Domain Expert Knowledge)5.2 目标图片上下文信息(Target Image Context) 六、How to use 最近在做缺陷检测&#…