当前位置:网站首页>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
边栏推荐
- 发生OOM了,你知道是什么原因吗,又该怎么解决呢?
- [Chongqing Guangdong education] reference materials for nine lectures on the essence of Marxist Philosophy in Wuhan University
- Global and Chinese markets of SERS substrates 2022-2028: Research Report on technology, participants, trends, market size and share
- 运维,放过监控-也放过自己吧
- O & M, let go of monitoring - let go of yourself
- Global and Chinese market of electric pruners 2022-2028: Research Report on technology, participants, trends, market size and share
- Redis分布式锁实现Redisson 15问
- Global and Chinese market of metallized flexible packaging 2022-2028: Research Report on technology, participants, trends, market size and share
- Redis之cluster集群
- 基于B/S的网上零食销售系统的设计与实现(附:源码 论文 Sql文件)
猜你喜欢
随机推荐
O & M, let go of monitoring - let go of yourself
Redis之发布订阅
Reids之删除策略
Global and Chinese markets for small seed seeders 2022-2028: Research Report on technology, participants, trends, market size and share
Connexion d'initialisation pour go redis
解决小文件处过多
英雄联盟轮播图手动轮播
Redis connection redis service command
面渣逆袭:Redis连环五十二问,图文详解,这下面试稳了
AcWing 2456. 记事本
五月刷题01——数组
CSP student queue
Vs All comments and uncomments
One article read, DDD landing database design practice
Global and Chinese market of electronic tubes 2022-2028: Research Report on technology, participants, trends, market size and share
为什么要数据分层
Blue Bridge Cup_ Single chip microcomputer_ PWM output
Use of activiti7 workflow
五月刷题27——图
Opencv+dlib realizes "matching" glasses for Mona Lisa