Leetcode_Valid Palindrome
来源:互联网 发布:怎么查手机的网络制式 编辑:程序博客网 时间:2024/05/19 17:02
判断字符串是否为对称的,主要是不考虑非字母非数字的字符。
class Solution {public: bool isPalindrome(string s) {if(s.size()==0)return true;int len=s.size();if(len==1){if(isalnum(s[0])) return true;else return false;}string::iterator first,last;first=s.begin();last=prev(s.end());while(first<last){if(isalnum(*first)&&isalnum(*last)&&(tolower(*first)!=tolower(*last))){return false;}if(isalnum(*first)&&isalnum(*last)&&(tolower(*first)==tolower(*last))){++first;--last;}if(!isalnum(*first)) ++first;if(!isalnum(*last)) --last;} return true; }};
0 0
- Leetcode_valid-palindrome
- Leetcode_Valid Palindrome
- leetcode_Valid Palindrome
- Leetcode_valid-parentheses
- Leetcode_valid-sudoku
- LeetCode_Valid Sudoku
- leetcode_Valid Number
- leetcode_Valid Parentheses
- leetcode_Valid Sudoku
- leetcode_Valid Anagram
- leetcode_Valid Anagram_easy
- LeetCode_Valid Parentheses
- LeetCode_valid-anagram
- leetCode_Valid Number
- leetcode_Valid Perfect Square
- palindrome
- Palindrome
- Palindrome
- 【Objective-C】13-类和方法的本质
- HDU -- 4786 Fibonacci Tree (mst)
- dramsim2地址映射
- 支付机构AID汇总
- Java中文乱码之一 文件编码与系统环境
- Leetcode_Valid Palindrome
- eclipse Maven构建的工程无法发布lib到tomcat的解决方法
- shell编程表达式求值
- ACM--steps--3.1.6--Tiling_easy version
- JAVA学习笔记36——泛型2:泛型继承、擦除+泛型接口+泛型无多态、通配符
- Hibernate学习:查询缓存
- c++ string in game
- 循环-17. 简单计算器(20)
- UIButton图片设置