当前位置:网站首页>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;
}
};边栏推荐
- UE4 制作遇到的问题
- Selenium:上传、下载文件
- 可持久化线段树
- The sword refers to Offer 68 - I. Nearest Common Ancestor of Binary Search Trees
- typescript24-类型推论
- MySQL Practice Summary -
- 力扣(LeetCode)212. 单词搜索 II(2022.07.31)
- typescript25 - type assertion
- ModuleNotFoundError: No module named ‘tensorflow.keras‘报错信息的解决方法
- LeetCode 27. 移除元素
猜你喜欢
随机推荐
pytorch、tensorflow对比学习—张量
程序员代码面试指南 CD15 生成窗口最大值数组
y83.第四章 Prometheus大厂监控体系及实战 -- prometheus告警机制进阶(十四)
Robot_Framework:断言
Selenium: element judgment
2022/07/29 入职健海JustFE团队,我学到了高效开发(年中总结)
LeetCode 9. 回文数
MySQL-Data Operation-Group Query-Join Query-Subquery-Pagination Query-Joint Query
API Design Notes: The pimpl trick
请问shake数据库中为什么读取100个collection 后,直接就退出了,不继续读了呢?
Seleniu:元素常用操作
typescript26-字面量类型
Selenium: element positioning
LeetCode 231. 2 的幂
pytroch、tensorflow对比学习—搭建模型范式(低阶、中阶、高阶API示例)
Selenium: browser operation
牛客多校2022第四场A,H,K,N
I met a shell script
pytroch、tensorflow对比学习—功能组件(数据管道、回调函数、特征列处理)
Malicious attacks on mobile applications surge by 500%









