当前位置:网站首页>leetcode125 验证回文串
leetcode125 验证回文串
2022-08-01 05:11:00 【老鱼37】
解法一:
class Solution {
public:
bool isPalindrome(string s) {
//可以考虑字符串的+=算法
//重新创建一个字符串
string goods;
for(int i=0;i<s.size();i++)
{
if(isalnum(s[i])) //判断是否为字母和数字
{
goods+=tolower(s[i]);
}
}
//全部转换成小写 或者 大写都可以
//定位
int begin=0;
int end=goods.size()-1;
while(begin<end)
{
if(goods[begin]!=goods[end])
{
return false;
}
++begin;
--end;
}
return true;
}
};
边栏推荐
- Power button (LeetCode) 212. The word search II (2022.07.31)
- pytorch、tensorflow对比学习—功能组件(激活函数、模型层、损失函数)
- 【目标检测】YOLOv7理论简介+实践测试
- [MySQL] 多表查询
- Dry goods!How to Construct SRv6-TE Performance Test Environment Using Instrumentation
- (2022牛客多校四)N-Particle Arts(思维)
- [target detection] YOLOv7 theoretical introduction + practical test
- (2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
- A,H,K,N
- (2022牛客多校四)K-NIO‘s Sword(思维)
猜你喜欢
万字逐行解析与实现Transformer,并进行德译英实战(一)
A,H,K,N
Selenium: Manipulating Cookies
MySQL-Data Definition Language-DDLdatebase define language
剑指 Offer 68 - I. 二叉搜索树的最近公共祖先
MySQL-数据定义语言-DDLdatebase define language
Lawyer Interpretation | Guns or Roses?Talking about Metaverse Interoperability from the Battle of Big Manufacturers
pytroch、tensorflow对比学习—专栏介绍
Robot_Framework: Assertion
Power button (LeetCode) 212. The word search II (2022.07.31)
随机推荐
UE4 从鼠标位置射出射线检测
Li Chi's work and life summary in July 2022
Pyspark Machine Learning: Vectors and Common Operations
李迟2022年7月工作生活总结
The difference between scheduleWithFixedDelay and scheduleAtFixedRate
LeetCode 231. 2 的幂
(2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
Selenium: JS operation
Selenium:鼠标、键盘事件
华为Android开发面试后得出的面试秘诀
PaddleX部署推理模型和GUI界面测试结果不一致的解决方法
API Design Notes: The pimpl trick
pytorch、tensorflow对比学习—张量
Swastika line-by-line parsing and realization of the Transformer, and German translation practice (2)
Selenium: Dropdown Box Actions
MySQL-Data Operation-Group Query-Join Query-Subquery-Pagination Query-Joint Query
Selenium: upload and download files
(2022牛客多校四)K-NIO‘s Sword(思维)
Selenium:弹窗处理
剑指 Offer 68 - II. 二叉树的最近公共祖先