当前位置:网站首页>LeetCode Daily 2 Questions 02: Number of Palindromes (1200 each)
LeetCode Daily 2 Questions 02: Number of Palindromes (1200 each)
2022-08-06 02:17:00 【The man was fishing for snow in the cold river alone.】

- Solution idea: first convert the integer type to string type, and then traverse, the array length/2 because the palindrome dates are in reverse order, the first digit and the penultimate digit are equal, the second digit and the penultimate digitThe two digits are equal, and so on, if they are not equal, return false, if they are equal, return true
class Solution {public boolean isPalindrome(int x) {String str = x + "";//1221 runs twicefor (int i = 0; i <str.length() / 2; i++) {if (str.charAt(i) != str.charAt(str.length() - 1 - i)) {Subtract one because it starts from 0 instead of 1 return false;}}return true;}}边栏推荐
- TS (TypeScript) variable type
- QT:用qt实现一个登录界面
- Wasabi Technologies adds Japanese and Australian executives to leadership team to support demand for hot cloud storage across Asia Pacific
- 海康威视秋招正式开始,快来和我做同事~
- 多线程-理解
- typescript73 - create your own type declaration files (shared types within the project)
- Wejo加入MONET联盟,进一步推动国际移动出行创新
- 【NOI模拟赛】独家墙(数位DP)
- 【无标题】
- 【回顾】基于树莓派下的4G模块(EC200U-CN)实现远程控制短信的收发
猜你喜欢

Online Question Feedback Module Actual Combat (20): Realize the function of batch exporting files to zip archives

Soul递交上市招股书,以技术为基石构建多元社交元宇宙

1320 _stm32f103 burn write programs using a serial port

产业园区实现产业集聚的三大举措

Students' illegal use of the database causes the school's IP to be permanently blocked

ansible copy 模块

#mysql错误01#

FTX交易所入榜福布斯2022金融科技50强名单

Soul submitted a listing application to the Hong Kong Stock Exchange and continued to develop the social metaverse track

向港交所递交招股书的Soul,如何以社交元宇宙俘获万千Z世代的心?
随机推荐
#mysql错误01#
6、NeRF in the Wild
产业园区实现产业集聚的三大举措
linux下mysql cpu占用过高问题查找思路
codeforces 50A.Domino piling
拦截器通过自定义注解来判断是否拦截
ftp 报错 227 Entering Passive Mode (192,168,169,141,213,232)
ansible command 模块
Wejo加入MONET联盟,进一步推动国际移动出行创新
STP实验
【2023秋招】金融技术类客观题整理
多线程-实现方式
SSH-KeyGen - Authentication key generation, management and conversion
SprinBoot自定义异常(统一异常处理)
快速查看Oracle数据库告警日志的存储位置
两数之和——LeetCode第一题
ansible setup 模块
FTX交易平台收购合规加密交易所 Bitvo,打开加拿大市场
package.json scripts 脚本的作用
Removal control of WPF screenshot control (9) "Imitation WeChat"