leetcode 之Valid Palindrome(26)
现在开始进入字符串系列。

判断回文串的。首尾各定义一个指针,然后相比较。难点在于如何提出非字母数字的字符。
bool isValidPalind(string s)
{
//转为小写,注意这个函数的用法
transform(s.begin(), s.end(), s.begin(), ::towlower);
auto left = s.begin(), right = prev(s.end()); while (left < right)
{
//首先判断是否是数字或字母
if (!::isalnum(*left))++left;
else if (!::isalnum(*right))right--; else if (*left != *right)return false;
else
{
left++;
right--;
} }
}
leetcode 之Valid Palindrome(26)的更多相关文章
- [LeetCode] 680. Valid Palindrome II 验证回文字符串 II
Given a non-empty string s, you may delete at most one character. Judge whether you can make it a pa ...
- [Leetcode][JAVA] Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- [leetcode] 1. Valid Palindrome
leetcode的第一题,回文数判断. 原题如下: For example, "A man, a plan, a canal: Panama" is a palindrome. & ...
- LeetCode 1216. Valid Palindrome III
原题链接在这里:https://leetcode.com/problems/valid-palindrome-iii/ 题目: Given a string s and an integer k, f ...
- [LeetCode] 125. Valid Palindrome 验证回文字符串
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- 【leetcode】Valid Palindrome
题目简述: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ...
- 【题解】【字符串】【Leetcode】Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- leetcode 125. Valid Palindrome ----- java
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- LeetCode 125. Valid Palindrome
这个题目只要注意大小写问题即可解决,而且我们只关注的是字母和数值 Given a string, determine if it is a palindrome, considering only a ...
- leetcode:Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
随机推荐
- Myhchael原创题系列 Mychael vs Kid 【题解】
题目链接 Mychael vs Kid 题解 先说说这题的由来及前身 前身 首先有一个很经典的题目: 维护区间加,查询区间\(gcd\) 如果强行用线段树维护的话,区间加之后就没法直接确定当前区间的\ ...
- mac, xcode 6.1 安装command line tools 支持,autoconf,automake等
以下软件包 都去我的环境库找到 1 先安装 tcl库 2 安装macports /opt/local/bin/port 一般装到这里 安装autoconf时提示: Warning: The Xcode ...
- nodejs获取文件信息,判断是文件或目录
var stat = fs.statSync(filename); console.log(stat) 输出 { dev: 0, ino: 0, mode: 33206, nlink: 1, uid: ...
- JavaScript正则表达式的浏览器的差异
JavaScript中的正则表达式在不同的浏览器中得到的结果可能会有差异,下面把正则表达式在五大主流浏览器(IE.Firefox.Chrome.Safari.Opera,以当前版本为准)之间的差异整理 ...
- mybatis中parameterType可以写的别名
mybatis中parameterType可以写的别名 https://blog.csdn.net/sdzhangshulong/article/details/51749807 _byte byte ...
- hzwer分块九题(暂时持续更新)
hzwer分块9题 分块1:区间加法,单点查询 Code #include<bits/stdc++.h> #define in(i) (i=read()) using namespace ...
- 整数中1出现的次数(从1到n整数中1出现的次数)
整数中1出现的次数(从1到n整数中1出现的次数) 题目描述 求出1 ~ 13的整数中1出现的次数,并算出100 ~ 1300的整数中1出现的次数?为此他特别数了一下1 ~ 13中包含1的数字有1.10 ...
- [LeetCode] 21. Merge Two Sorted Lists ☆
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing t ...
- UVA 580 Critical Mass
https://vjudge.net/problem/UVA-580 题意:一堆U和L,用n个排成一排,问至少有3个U放在一起的方案数 f[i] 表示 至少有3个U放在一起的方案数 g[i] 表示没有 ...
- Spring mvc 增加静态资源配置后访问不了注解配置的controller
spring mvc 增加静态资源访问配置. 例如: <!-- 静态资源映射 --> <mvc:resources location="/static/" map ...