leetcode26:valid-palindrome
题目描述
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? This 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:
/**
*
* @param s string字符串
* @return bool布尔型
*/
bool isPalindrome(string s) {
int i,j;
for(i=0,j=s.length()-1;i<j;++i,--j){
while(i<j && !isalnum(s[i])) ++i;
while(i<j && !isalnum(s[j])) --j;
if (i<j && tolower(s[i])!=tolower(s[j])) return false;
}
return true;
}
};
leetcode26:valid-palindrome的更多相关文章
- [LeetCode] 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 ...
- [LintCode] Valid Palindrome 验证回文字符串
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- [LeetCode]题解(python):125 Valid Palindrome
题目来源 https://leetcode.com/problems/valid-palindrome/ Given a string, determine if it is a palindrome ...
- 25. Valid Palindrome
Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric char ...
- [Leetcode][JAVA] Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- Valid Palindrome [LeetCode]
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- 【LeetCode OJ】Valid Palindrome
Problem Link: http://oj.leetcode.com/problems/valid-palindrome/ The following two conditions would s ...
- 【题解】【字符串】【Leetcode】Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
随机推荐
- matlab中fspecial Create predefined 2-D filter以及中值滤波均值滤波以及高斯滤波
来源: 1.https://ww2.mathworks.cn/help/images/ref/fspecial.html?searchHighlight=fspecial&s_tid=doc_ ...
- 图像sensor的bitdepth
参考来源:https://blog.csdn.net/yuejisuo1948/article/details/83617359 bitdepth目前个人理解是sensor像素上表示颜色的范围,也可说 ...
- matlab中get查询图形对象属性
来源:https://ww2.mathworks.cn/help/matlab/ref/get.html?searchHighlight=get&s_tid=doc_srchtitle get ...
- linux下各种骚操作
(备注:不定时更新) 1. ctrl+l 清屏快捷键,相当于clear 2. !+命令开头部分 执行最近执行的此条命令 ### 如!vi 编辑上一次用vi打开的文件, 3. echo $$ ...
- Lane-Detection 近期车道线检测论文阅读总结
近期阅读的几篇关于车道线检测的论文总结. 1. 车道线检测任务需求分析 1.1 问题分析 针对车道线检测任务,需要明确的问题包括: (1)如何对车道线建模,即用什么方式来表示车道线. 从应用的角度来说 ...
- Prometheus 系列开篇:为什么要学 Prometheus ?
「Prometheus 系列开篇:为什么要学 Prometheus ?」首发于[陈树义]公众号,点击跳转到原文https://mp.weixin.qq.com/s/HCS6X3l6nVBw_hAnd6 ...
- MeteoInfoLab脚本示例:天气现象符号
天气现象符号分布图实际就是散点图,可以用scatterm函数绘制,但之前需要创建天气符号图例,用weatherspec函数.如果只需要绘制某些天气现象(比如雾.霾),可以给出相应的天气符号序号列表(可 ...
- 【贪心算法】CF Emergency Evacuation
题目大意 vjudge链接 给你一个车厢和一些人,这些人都坐在座位上,求这些人全部出去的时间最小值. 样例1输入 5 2 71 11 21 32 32 44 45 2 样例1输出 9 样例2输入 50 ...
- 第十八章 vi/vim文本编辑器介绍
一.vi/vim文本编辑器介绍 1.含义: vi就是一个文本编辑器 2.为什么学习: 系统配置 编写脚本 vim就是vi的升级版 高级版 [root@jindada ~]# [root@jindada ...
- C++学习---二叉树的输入及非递归遍历
二叉树的二叉链表存储表示如下 //二叉树的二叉链表存储表示 typedef struct BiTNode { char data;//结点数据域 struct BiTNode* lchild, * r ...