当前位置:网站首页>LeetCode刷题(04)
LeetCode刷题(04)
2022-04-22 14:17:00 【Kinest】
题目描述
给你一个整数 x ,如果 x 是一个回文整数,返回 true ;否则,返回 false 。
回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。
例如,121 是回文,而 123 不是。
题解
class Solution {
public boolean isPalindrome(int x) {
String s = String.valueOf(x);
int length = s.length();
int right = length - 1;
for (int i = 0; i <= right; i++) {
//用right代替length
if (s.charAt(i) != s.charAt(right)) {
return false;
}
right--;
}
return true;
}
}
版权声明
本文为[Kinest]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_45892612/article/details/124220867
边栏推荐
- Binary Tree练习二叉树遍历递归257、100、222、101、226、437、563、617、572、543、|687
- Redis相比memcached
- Byte beating interview sharing, in order to win this offer, who knows what I have experienced
- Dynamic gauge initial solution 𞓜 maximum subsequence and longest ascending subsequence 53 and 128
- 独立站运营 | 6个Facebook推广小技巧,你都知道吗?
- Tools applicable to any database - Shanghai daoning brings a powerful general database management tool dbeaver to developers and database administrators
- Hashtable hash table practice finding, inserting, deleting 217, 349, 202, 287, 290, 532, 205, 128
- Binarytree练习二叉树层序遍历 || 用队列实现层序遍历
- Cloudera Manager HA模式搭建
- 【pytorch】自己实现精简版YOLOV3【五】,实现YOLOV3损失函数(一)
猜你喜欢

BinaryTree练习 从前序与中序、中序与后序遍历序列构造二叉树||重构二叉树654、105、106
![[robot learning] learning record of mobile robot odometer](/img/cb/37155ad01a9f998a0477becbdcb9fa.jpg)
[robot learning] learning record of mobile robot odometer

Eight strange facts about semiconductors

定时器--

我为什么那么爱用飞项做任务管理

多线程初阶

Linked list ring linked list linked list ring judgment to find the ring in nodes 141 and 142

嵌入式软件bug从哪来,怎么去

Solution to the blank page of small and medium-sized programs running from uniapp to wechat developer tool

Activity preview | on April 23, a number of wonderful openmldb sharing came, which lived up to the good time of the weekend!
随机推荐
20道25K+Android工程师面试必问面试题,网易Android面试必问
Figure keys and rooms
10天完成民猫电商毕设——用户模块实现(2nd day)
双指针||有序数组去重 排序链表移除元素 26、27、83
深入剖析Lock与AQS
Binary Tree练习二叉树遍历递归257、100、222、101、226、437、563、617、572、543、|687
BinaryTree练习 从前序与中序、中序与后序遍历序列构造二叉树||重构二叉树654、105、106
微信小程序商城项目实战(第六篇:商品搜索)
C语言的三子棋,用22天总结了一份完美的SQL学习笔记
Exercises and answers for the examination of main principals of hazardous chemical business units in 2022
Redis connection tool cannot connect to redis in docker
知识就是力量,但更重要的是运用知识的能力---网页端微信扫码支付-技术设计
深入理解读写锁ReentrantReadWriteLock和并发容器CopyOnWriteArrayList
Qt创建窗口闪退的问题
makefile 调用bash脚本遇到的坑
spark代码 spark-submit提交yarn-cluster模式
What is adapter mode?
Dynamic gauge initial solution 𞓜 maximum subsequence and longest ascending subsequence 53 and 128
Development and application of deep learning technology
HashTable哈希表与统计594、350、|554、609、454、18