当前位置:网站首页>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;
}
};
边栏推荐
- The sword refers to Offer 68 - I. Nearest Common Ancestor of Binary Search Trees
- pytorch、tensorflow对比学习—功能组件(优化器、评估指标、Module管理)
- ApiFile
- 类神经网络训练不起来怎么办
- Typescript20 - interface
- 小心你的字典和样板代码
- Selenium: browser operation
- 微信小程序接口调用凭证(获取token)auth.getAccessToken接口开发
- Selenium: Introduction
- typescript27 - what about enumeration types
猜你喜欢
(2022牛客多校四)N-Particle Arts(思维)
Lawyer Interpretation | Guns or Roses?Talking about Metaverse Interoperability from the Battle of Big Manufacturers
(2022 Nioke Duo School IV) H-Wall Builder II (Thinking)
初识shell脚本
类神经网络训练不起来怎么办
pytroch、tensorflow对比学习—功能组件(数据管道、回调函数、特征列处理)
The solution to the inconsistency between the PaddleX deployment inference model and the GUI interface test results
API Design Notes: The pimpl trick
[MySQL] 多表查询
The method of solving stored procedure table name passing through variable in mysql
随机推荐
UE4 制作遇到的问题
Excel record of integer programming optimization model to solve the problem
图片更新之后Glide加载依旧是原来的图片问题
typescript27 - what about enumeration types
状态压缩dp
ModuleNotFoundError: No module named 'tensorflow.keras' error message solution
typescript25 - type assertion
2022/07/29 入职健海JustFE团队,我学到了高效开发(年中总结)
Robot_Framework: keyword
微信小程序接口调用凭证(获取token)auth.getAccessToken接口开发
25. 这三道常见的面试题,你有被问过吗?
用控件当画笔获得bitmap代码记录
万字逐行解析与实现Transformer,并进行德译英实战(二)
MySQL-Data Operation-Group Query-Join Query-Subquery-Pagination Query-Joint Query
High Numbers | 【Re-integration】Line Area Score 880 Examples
In the shake database, I want to synchronize the data of the source db0 to the destination db5, how to set the parameters?
typescript26-字面量类型
LeetCode 387. 字符串中的第一个唯一字符
报错:AttributeError: module ‘matplotlib’ has no attribute ‘figure’
Pyspark Machine Learning: Vectors and Common Operations