Advertisement

LeetCode-326-验证字符串是否是回文

阅读量:
在这里插入图片描述

策略一:筛选机制结合逆向判定法

复制代码
    class Solution 
    {
    public:
    	bool isPalindrome(string s)
    	{
    		string tmp;
    		for (auto& x : s)
    		{
    			if (isalnum(x))
    			{
    				tmp += tolower(x);
    			}
    		}
    		string tmp_tmp(tmp.rbegin(), tmp.rend());
    		return tmp_tmp == tmp;
    	}
    };
    int main()
    {
    	Solution A;
    	cout << A.isPalindrome("") << endl;
    	return 0;
    }
    
    
      
      
      
      
      
      
      
      
      

全部评论 (0)

还没有任何评论哟~