1,Vaild Palindrome

leetcode 字符串类型题
 1 bool isPalindrome(string& s) {
 2     transform(s.begin(), s.end(), s.begin(), tolower); // 把字符全部转换成小写
 3     int left = 0;
 4     int right = s.length()-1;
 5     while (left < right) {
 6         if (!isalnum(s[left])) ++left;
 7         else if (!isalnum(s[right])) --right;
 8         else if (s[left] != s[right]) return false;
 9         else {
10             ++left;
11             --right;
12         }
13     }
14     return true;
15 }
isPalindrome

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2021-12-14
  • 2021-05-16
  • 2021-10-24
  • 2021-09-01
  • 2021-12-08
猜你喜欢
  • 2021-12-02
  • 2021-10-24
相关资源
相似解决方案