当前位置:网站首页>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
边栏推荐
- Redis之Lua脚本
- [deep learning] semantic segmentation: paper reading: (2021-12) mask2former
- 软件负载均衡和硬件负载均衡的选择
- Redis cluster
- What is an R-value reference and what is the difference between it and an l-value?
- Basic usage of xargs command
- Design and implementation of film and television creation forum based on b/s (attached: source code paper SQL file project deployment tutorial)
- Workflow - activiti7 environment setup
- Redis之性能指标、监控方式
- Processes of libuv
猜你喜欢

Redis connection redis service command

【深度学习】语义分割:论文阅读:(2021-12)Mask2Former

基于B/S的医院管理住院系统的研究与实现(附:源码 论文 sql文件)

QML control type: Popup

MapReduce工作机制

【深度学习】语义分割:论文阅读:(CVPR 2022) MPViT(CNN+Transformer):用于密集预测的多路径视觉Transformer

IDS cache preheating, avalanche, penetration

Oom happened. Do you know the reason and how to solve it?

Opencv+dlib realizes "matching" glasses for Mona Lisa

为拿 Offer,“闭关修炼,相信努力必成大器
随机推荐
Redis之Geospatial
为拿 Offer,“闭关修炼,相信努力必成大器
QML control type: menu
有软件负载均衡,也有硬件负载均衡,选择哪个?
解决小文件处过多
Research and implementation of hospital management inpatient system based on b/s (attached: source code paper SQL file)
Global and Chinese markets for small seed seeders 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market for annunciator panels 2022-2028: Research Report on technology, participants, trends, market size and share
Scoped in webrtc_ refptr
The five basic data structures of redis are in-depth and application scenarios
Chapter 1 :Application of Artificial intelligence in Drug Design:Opportunity and Challenges
【shell脚本】使用菜单命令构建在集群内创建文件夹的脚本
Kratos战神微服务框架(三)
[three storage methods of graph] just use adjacency matrix to go out
Design and implementation of film and television creation forum based on b/s (attached: source code paper SQL file project deployment tutorial)
Persistence practice of redis (Linux version)
五层网络体系结构
七层网络体系结构
MapReduce instance (IV): natural sorting
五月刷题27——图