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 ...
随机推荐
- BZOJ 1051 最受欢迎的牛 解题报告
题目直接摆在这里! 1051: [HAOI2006]受欢迎的牛 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 4438 Solved: 2353[S ...
- The Angles of a Triangle
The Angles of a Triangle You are given the lengths for each side on a triangle. You need to find all ...
- Jedis超时时间设置梳理
JedisConnectionException: Unexpected end of stream #932 Repeatable exception and for the life of me, ...
- java本地方法
一. 什么是Native Method 简单地讲,一个Native Method就是一个java调用非java代码的接口.一个Native Method是这样一个java的方法:该方法的实现由非j ...
- C# 给枚举类型增加一个描述特性
前言 相信很多人对枚举并不陌生,枚举可以很方便和直观的管理一组特定值.如果我们在页面上直接输出我们希望匹配的汉语意思或则其他满足我们需求的语句就更好了,当然,通常小伙伴们都会再页面上if(enum== ...
- 同一个世界(erlang解题答案)
最近玩同一个世界,才几关就把3次提示用完了,十分气愤, 于是写了程序来解~~~ o(^▽^)o 以2-1为例子,题目如下 以0代表白色,1代表黑色,抽象的就是这样的 ----------------- ...
- javascript---对象和函数的引用、浅拷贝、深拷贝、递归
1.javascript 对象和函数的引用 <!doctype html> <html lang="en"> <head> <meta c ...
- C语言求最小公倍数和最大公约数三种算法
最小公倍数:数论中的一种概念,两个整数公有的倍数成为他们的公倍数,其中一个最小的公倍数是他们的最小公倍数,同样地,若干个整数公有的倍数中最小的正整数称为它们的最小公倍数,维基百科:定义点击打开链接 求 ...
- 第14章5节《MonkeyRunner源代码剖析》 HierarchyViewer实现原理-装备ViewServer-查询ViewServer执行状态
上一小节我们描写叙述了HierarchyViewer是怎样组建ADB协议命令来实现ViewServer的port转发的.在port转发设置好后,下一个要做的事情就是去检測目标设备端ViewServer ...
- STM32L0开发——ADC多通道采集,IDE和IAR开发注意事项
keil开发L0系列是免费的,官方提供许可的.因此建议Keil开发,L011F3由于flash只有8K,因此不建议HAL库,建议使用cubemx+LL(或snippets库).0.起初,可以参考官方库 ...