当前位置:网站首页>018.有效的回文
018.有效的回文
2022-07-06 09:01:00 【棱镜7】
一、code
1.1 题目描述
1.2 题解
class Solution {
public boolean isPalindrome(String s) {
int i = 0;
int j = s.length() - 1;
while(i < j){
char ch1 = s.charAt(i);
char ch2 = s.charAt(j);
if(!Character.isLetterOrDigit(ch1)){
i++;
continue;
}
if(!Character.isLetterOrDigit(ch2)){
j--;
continue;
}
ch1 = Character.toLowerCase(ch1);
ch2 = Character.toLowerCase(ch2);
if(ch1 != ch2){
return false;
}
i++;
j--;
}
return true;
}
}
二、总结
String类:
- s.charAt() 方法用于返回指定索引处的字符。索引范围为从 0 到 length() - 1。
Character类:
- Character.isLetterOrDigit() //判断是字符or数字
- Character.isLowerCase()/Character.isUpperCase() //判断大小写
-Character.toLowerCase()/Character.toUpperCase() //转化大小写
边栏推荐
- Advanced Computer Network Review(4)——Congestion Control of MPTCP
- xargs命令的基本用法
- Pytest's collection use case rules and running specified use cases
- Nacos installation and service registration
- postman之参数化详解
- [oc foundation framework] - < copy object copy >
- CUDA implementation of self defined convolution attention operator
- Publish and subscribe to redis
- 【shell脚本】——归档文件脚本
- Global and Chinese market of bank smart cards 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
![[text generation] recommended in the collection of papers - Stanford researchers introduce time control methods to make long text generation more smooth](/img/10/c0545cb34621ad4c6fdb5d26b495ee.jpg)
[text generation] recommended in the collection of papers - Stanford researchers introduce time control methods to make long text generation more smooth

Activiti7工作流的使用

Once you change the test steps, write all the code. Why not try yaml to realize data-driven?

Heap (priority queue) topic

KDD 2022论文合集(持续更新中)

Post training quantification of bminf
![[shell script] - archive file script](/img/50/1bef6576902890dfd5771500414876.png)
[shell script] - archive file script

工作流—activiti7环境搭建

Design and implementation of online shopping system based on Web (attached: source code paper SQL file)

一改测试步骤代码就全写 为什么不试试用 Yaml实现数据驱动?
随机推荐
【每日一题】搬运工 (DFS / DP)
Design and implementation of online shopping system based on Web (attached: source code paper SQL file)
Withdrawal of wechat applet (enterprise payment to change)
A convolution substitution of attention mechanism
Activiti7工作流的使用
Redis之Bitmap
Full stack development of quartz distributed timed task scheduling cluster
Sqlmap installation tutorial and problem explanation under Windows Environment -- "sqlmap installation | CSDN creation punch in"
Le modèle sentinelle de redis
KDD 2022论文合集(持续更新中)
Master slave replication of redis
Pytest之收集用例规则与运行指定用例
Redis之Lua脚本
数据建模有哪些模型
基于B/S的影视创作论坛的设计与实现(附:源码 论文 sql文件 项目部署教程)
Mysql database recovery (using mysqlbinlog command)
数字人主播618手语带货,便捷2780万名听障人士
Ijcai2022 collection of papers (continuously updated)
Global and Chinese market of airport kiosks 2022-2028: Research Report on technology, participants, trends, market size and share
一文读懂,DDD落地数据库设计实战