当前位置:网站首页>018. Valid palindromes
018. Valid palindromes
2022-07-06 09:34:00 【Prism 7】
List of articles
One 、code
1.1 Title Description
1.2 Answer key
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;
}
}
Two 、 summary
String class :
- s.charAt() Method to return the characters at the specified index . Index range is from 0 To length() - 1.
Character class :
- Character.isLetterOrDigit() // Judge is character or Numbers
- Character.isLowerCase()/Character.isUpperCase() // Determine case
-Character.toLowerCase()/Character.toUpperCase() // Convert case
边栏推荐
- Publish and subscribe to redis
- 发生OOM了,你知道是什么原因吗,又该怎么解决呢?
- Multivariate cluster analysis
- Reids之删除策略
- 【深度学习】语义分割:论文阅读(NeurIPS 2021)MaskFormer: per-pixel classification is not all you need
- DCDC power ripple test
- Redis cluster
- Connexion d'initialisation pour go redis
- Parameterization of postman
- leetcode-14. Longest common prefix JS longitudinal scanning method
猜你喜欢
Mapreduce实例(十):ChainMapReduce
The carousel component of ant design calls prev and next methods in TS (typescript) environment
MapReduce工作机制
基于WEB的网上购物系统的设计与实现(附:源码 论文 sql文件)
基于B/S的影视创作论坛的设计与实现(附:源码 论文 sql文件 项目部署教程)
Mapreduce实例(六):倒排索引
Blue Bridge Cup_ Single chip microcomputer_ PWM output
Minio distributed file storage cluster for full stack development
Kratos战神微服务框架(二)
【深度学习】语义分割:论文阅读(NeurIPS 2021)MaskFormer: per-pixel classification is not all you need
随机推荐
Mapreduce实例(六):倒排索引
[Yu Yue education] Wuhan University of science and technology securities investment reference
Redis之性能指标、监控方式
Redis' performance indicators and monitoring methods
AcWing 2456. Notepad
Five layer network architecture
五月刷题26——并查集
Advanced Computer Network Review(4)——Congestion Control of MPTCP
Redis之Lua脚本
Go redis initialization connection
【shell脚本】使用菜单命令构建在集群内创建文件夹的脚本
Redis之连接redis服务命令
Global and Chinese markets for small seed seeders 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market of appointment reminder software 2022-2028: Research Report on technology, participants, trends, market size and share
Blue Bridge Cup_ Single chip microcomputer_ PWM output
Advance Computer Network Review(1)——FatTree
xargs命令的基本用法
Global and Chinese market of capacitive displacement sensors 2022-2028: Research Report on technology, participants, trends, market size and share
Redis connection redis service command
【深度学习】语义分割:论文阅读(NeurIPS 2021)MaskFormer: per-pixel classification is not all you need