字符串 -- 3.1 Valid Palindrome -- 图解
/**********************************************************************************************************
描述
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring
cases.
For example,
”A man, a plan, a canal: Panama” is a palindrome.
”race a car” is not a palindrome.
Note: Have you consider that the string might be empty? is is a good question to ask during an
interview.
For the purpose of this problem, we define empty string as valid palindrome
**********************************************************************************************************/
class Solution{
public:bool isPalindrome(string s){tranform(s.begin(),s.end(),s.begin(),::tolower);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;}return true;}
};
参考资料:
LeetCode题解
字符串 -- 3.1 Valid Palindrome -- 图解相关推荐
- 【LeetCode 剑指offer刷题】字符串题12:Valid Palindrome(回文词系列)
[LeetCode & 剑指offer 刷题笔记]目录(持续更新中...) Valid Palindrome Given a string, determine if it is a pali ...
- 验证字符串是否回文 Valid Palindrome
为什么80%的码农都做不了架构师?>>> 问题: Given a string, determine if it is a palindrome, considering on ...
- LeetCode 125 Valid Palindrome(有效回文)(*)
版权声明:转载请联系本人,感谢配合!本站地址:http://blog.csdn.net/nomasp https://blog.csdn.net/NoMasp/article/details/5062 ...
- [LeetCode] Palindrome Number Valid Palindrome - 回文系列问题
题目概述: Determine whether an integer is a palindrome. Do this without extra space. 题目分析: 判断数字是否是回文 例如1 ...
- Leet Code OJ 125. Valid Palindrome [Difficulty: Easy]
题目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ig ...
- valid Palindrome -- leetcode
125 Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric ...
- LeetCode 125. Valid Palindrome
题目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ig ...
- C#LeetCode刷题之#125-验证回文串(Valid Palindrome)
问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3899 访问. 给定一个字符串,验证它是否是回文串,只考虑字母和数 ...
- 125 Valid Palindrome
125 Valid Palindrome 链接:https://leetcode.com/problems/valid-palindrome/ 问题描写叙述: Given a string, dete ...
- leetcode python3 简单题125. Valid Palindrome
1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第一百二十五题 (1)题目 英文: Given a string, determin ...
最新文章
- 方法 注释_注释模板导入操作方法
- sql server中的hash应用优化
- AI真人表情包、斗地主AI......DeeCamp学员做了50个好玩又实用的AI项目
- ASP的DES加密解密
- 白色flash模块代码_适用于MCU项目的代码框架BabyOS,工程师的好助手!
- 广元南山隧道南河互通立交图_广元城区一隧道工程竣工时间已定,今后出行更加方便了!...
- 【HDU - 5700】【51nod - 1672】 区间交(贪心,STLset 或线段树第k大)
- vue项目导入elementui_在vue项目中使用elementui
- JimuReport积木报表 — API数据源报表带参制作
- Java基础——0 前言
- python 通过js控制滚动条拉取全文 通过psutil获取pid窗口句柄,通过win32gui使程序窗口前置 通过autopy实现右键菜单和另存为操作...
- linux的telnet
- 小米4 win10 刷回android,小米4怎么从win10刷回MIUI 小米4 win10刷回MIUI系统详细教程...
- 深入理解Binder机制1-AIDL原理
- 杰奇2.4珊瑚模板简繁转换出现乱码怎么解决
- 剑指Offer面试题11(Java版):数值的整数次方
- PS电商插件/图牛助理插件/多模板电商工具/Adobe Photoshop CC 2015-2022可直接使用的ps插件
- week1:History: Dawn of Electronic Computing
- Git 分支合并情况
- 什么是 NFT 洗盘交易:洗盘交易背后的原理