C++ 4 lines


  • 0
    T
    bool isPalindrome(string s) {
      string low;
      for (auto k:s) if (isalnum(k)) low += tolower(k);
      string rev(low.rbegin(), low.rend());
      return rev.compare(low) == 0;
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.