当前位置:网站首页>Leetcode judge whether palindrome number
Leetcode judge whether palindrome number
2022-07-28 02:33:00 【Lao Wang loves to knock code】
/** * Give you an integer x , If x Is a palindrome integer , return true ; otherwise , return false . * <p> * Palindrome number refers to positive order ( From left to right ) Reverse order ( From right to left ) Read all the same integers . * <p> * for example ,121 It's palindrome. , and 123 No . * <p> * source : Power button (LeetCode) * link :https://leetcode.cn/problems/palindrome-number * * @param x * @return */
public static boolean isPalindrome(int x) {
String numStr = String.valueOf(x);
StringBuilder stringBuilder = new StringBuilder(numStr);
stringBuilder.reverse();
return stringBuilder.toString().equals(numStr);
}Ideas :
utilize java Of string function , Reverse string , Then compare the contents before and after inversion
边栏推荐
- Get the difference data of two sets
- JVM tuning -xms -xmx -xmn -xss
- How MySQL uses indexes (glory Collection Edition)
- Promise from introduction to mastery (Chapter 4 async and await)
- 1313_pyserial的安装以及文档的生成
- Promise from getting started to mastering (Chapter 3: customize (handwriting) promise)
- Promise from introduction to mastery (Chapter 2 understanding and use of promise)
- MySQL高可用和主从同步
- 【HCIP】BGP 特性
- [hcip] routing strategy, strategic routing
猜你喜欢

怎么简单实现菜单拖拽排序的功能

APP如何上架App Store?

Appium click operation sorting

Deep Residual Learning for Image Recognition浅读与实现

关于Sqli-labs单引号不报错的问题

Go learning 01

Read Plato & nbsp; Eplato of farm and the reasons for its high premium

LeetCode 热题 HOT 100 -> 2.两数相加

Emotional drama in the world Zhou Bingkun lost his job because he saw Tu Zhiqiang and was shot

Ceresdao: new endorsement of ventures Dao
随机推荐
小程序毕设作品之微信校园维修报修小程序毕业设计成品(4)开题报告
Leetcode hot topic Hot 100 - > 2. Add two numbers
1313_pyserial的安装以及文档的生成
How to put app on the app store?
MySQL create stored procedure ------ [hy000][1418] this function has none of deterministic, no SQL
SkyWalking分布式系统应用程序性能监控工具-中
实际工作中,我是如何使用 Postman 做接口测试?
组原必备知识点
Class notes (5) (1) - 593. Binary search
OBS keyboard plug-in custom DIY
Appium click operation sorting
Which database is the fastest to query data only?
MySQL锁系列之锁算法详解(荣耀典藏版)
The cooperation between starfish OS and metabell is just the beginning
Smart contract security -- selfdestroy attack
MYSQL解决死锁之路 - 常见 SQL 语句的加锁分析
软考 --- 数据库(2)关系模型
[机缘参悟-53]:阳谋立身,阴谋防身
In practical work, how do I use postman for interface testing?
What problems should be avoided when using BigDecimal type? (glory Collection Edition)