【LeetCode-cpp】【37】125-验证回文串 Valid Palindrome
2020-06-08 05:20
351 查看
标签:双指针
难度:Easy
说是双指针,实际上双指针是这题最简单的部分,所以不如说这是个字符串题,islower和isdigit可以判断加入tmp之中。然后正常双指针。
[code]class Solution { public: bool isPalindrome(string s) { if(s.size() == 1 || s.size()==0) return true; string tmp; for(auto c:s){ if(islower(c)||isdigit(c)) tmp+=c; else if(isupper(c)) tmp+=(c+32);//把c加到tmp中的字符串操作才是这个题的重点 } int i = 0, j = tmp.size()-1; while(i<j){ if(tmp[i]!=tmp[j]) return false; i++;j--; } return true; } };
相关文章推荐
- leetcode(js)-每日一练之 验证回文串 题库编号125
- LeetCode125-验证回文串
- leetcode-125-验证回文串
- leetcode 125 验证回文串
- leetcode-125-验证回文串
- leetcode125. 验证回文串
- leetcode--验证回文字符串(125,680)
- 125. 验证回文串
- leetcode(js)-每日一练之 验证回文串Ⅱ 题库编号680
- Python LeetCode(125.验证回文串)
- LeetCode 125.验证回文串
- LeetCode 125. 验证回文串
- LeetCode-125.验证回文串(相关话题:字符串)
- LeetCode【125. 验证回文串】
- 验证回文串 - LeetCode
- LeetCode 125.验证回文串
- [leetcode]验证回文串[javascript]
- Leetcode 125. 验证回文串
- LeetCode - 125. 验证回文串
- 125、验证回文串