当前位置:网站首页>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 method of solving stored procedure table name passing through variable in mysql
typescript20-接口
零序电流继电器器JL-8C-12-2-2
MySQL-数据操作-分组查询-连接查询-子查询-分页查询-联合查询
可视化全链路日志追踪
中国的机器人增长
56:第五章:开发admin管理服务:9:开发【文件上传到,MongoDB的GridFS中,接口】;(把文件上传到GridFS的SOP)
【MySQL必知必会】 表的优化 | 充分利用系统资源
typescript23-tuple
Typescript20 - interface
随机推荐
PAT class B 1001 (3n+1) conjecture
【目标检测】YOLOv7理论简介+实践测试
The solution to the inconsistency between the PaddleX deployment inference model and the GUI interface test results
万字逐行解析与实现Transformer,并进行德译英实战(一)
移动应用恶意攻击激增500% 三六零天御为APP免费构建安全屏障
微信小程序获取手机号phonenumber.getPhoneNumber接口开发
typescript24-类型推论
混合型界面:对话式UI的未来
UE4 制作遇到的问题
ModuleNotFoundError: No module named ‘tensorflow.keras‘报错信息的解决方法
Selenium: JS operation
API Design Notes: The pimpl trick
剑指 Offer 68 - I. 二叉搜索树的最近公共祖先
The method of solving stored procedure table name passing through variable in mysql
typescript23-tuple
4D line-by-line analysis and implementation of Transformer, and German translation into English (3)
typescript27 - what about enumeration types
Typescript22 - interface inheritance
typescript28 - value of enumeration type and data enumeration
Selenium:下拉框操作