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 ...
随机推荐
- Docker入门手册
20.Docker 20.1 Docker的起源 2010年,几个搞IT的年轻人,在美国旧金山成立了一家名叫"dotCloud"的公司,这家公司主要提供基于PaaS的云计算技术服务 ...
- Linux为STDOUT的关键字设置颜色
echo "颜色测试aaa实测" | perl -pe 's/(aaa|实|测)/\e[1;31m$1\e[0m/g'
- .NET 云原生架构师训练营(模块一 架构师与云原生)--学习笔记
目录 什么是软件架构 软件架构的基本思路 单体向分布式演进.云原生.技术中台 1.1 什么是软件架构 1.1.1 什么是架构? Software architecture = {Elements, F ...
- 透视HTTPS建造固若金汤的城堡
为什么有 HTTPS?因为 HTTP 不安全! 现在的互联网已经不再是 "田园时代","黑暗森林" 已经到来.上网的记录会被轻易截获,网站是否真实也无法验证,黑 ...
- volatile型变量语义讲解一 :对所有线程的可见性
volatile型变量语义讲解一 :对所有线程的可见性 一.volatile变量语义一的概念 当一个变量被定义成volatile之后,具备两个特性: 特性一:保证此变量对所有线程的可见性.这里的&qu ...
- ie 版本判断脚本
// 获取IE版本 /** * @return {string} */ function IEVersion() { // 取得浏览器的userAgent字符串 var userAgent = nav ...
- 多测师讲解requests __中_高级讲师肖sir
(1)生成报告 import unittest #导入单元测试框架 import requests #导入接口库 import time # #时间戳,导入time模块 from api.HTMLTe ...
- jmeter 相关
Don't use GUI mode for load testing !, only for Test creation and Test debugging. For load testing, ...
- PHP 超级全局变量 $_GET
https://www.php.cn/php/php-superglobals.html https://m.php.cn/code/11853.html
- go 结构体函数
package main import "fmt" type Dog struct { Name string } func (d *Dog) speak() string { r ...