当前位置:网站首页>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;
}
};边栏推荐
- ModuleNotFoundError: No module named ‘tensorflow.keras‘报错信息的解决方法
- 关于给Qt做一个软件初始化的进度条
- pytorch、tensorflow对比学习—张量
- 剑指 Offer 68 - II. 二叉树的最近公共祖先
- Selenium:鼠标、键盘事件
- Swastika line-by-line parsing and realization of the Transformer, and German translation practice (2)
- 挑战52天背完小猪佩奇(第01天)
- Selenium:下拉框操作
- Selenium:元素定位
- (Codeforce 757)E. Bash Plays with Functions(积性函数)
猜你喜欢
随机推荐
请问shake数据库中为什么读取100个collection 后,直接就退出了,不继续读了呢?
MySQL-数据定义语言-DDLdatebase define language
类神经网络训练不起来怎么办
4D line-by-line analysis and implementation of Transformer, and German translation into English (3)
剑指 Offer 68 - II. 二叉树的最近公共祖先
(more than 2022 cattle school four) A - Task Computing + dynamic programming (sort)
Typescript20 - interface
LeetCode 1189. “气球” 的最大数量
PAT class B 1001 (3n+1) conjecture
The difference between scheduleWithFixedDelay and scheduleAtFixedRate
【MySQL必知必会】 表的优化 | 充分利用系统资源
pytorch、tensorflow对比学习—功能组件(激活函数、模型层、损失函数)
Selenium:简介
Swastika line-by-line parsing and realization of the Transformer, and German translation practice (a)
MySQL实践总结-
Lawyer Interpretation | Guns or Roses?Talking about Metaverse Interoperability from the Battle of Big Manufacturers
程序员代码面试指南 CD15 生成窗口最大值数组
Selenium:浏览器操作
I met a shell script
Pyspark Machine Learning: Vectors and Common Operations









![[MySQL] 多表查询](/img/f0/c158750a5a84155ee82729daba2bb3.png)