当前位置:网站首页>Leetcode -- number of palindromes
Leetcode -- number of palindromes
2022-07-02 16:01:00 【Nanchu】
Title Description
- Give you an integer x , If x Is a palindrome integer , return true ; otherwise , return false .
- Palindrome number refers to positive order ( From left to right ) Reverse order ( From right to left ) Read all the same integers . for example ,121 It's palindrome. , and 123 No .
- Example 1:
- Input :x = 121
- Output :true
- Example 2:
- Input :x = -121
- Output :false
- explain : Read left to right , by -121 . Read right to left , by 121- . So it's not a palindrome number .
- Example 3:
- Input :x = 10
- Output :false
- explain : Read right to left , by 01 . So it's not a palindrome number .
- Example 4:
- Input :x = -101
- Output :false
How to solve the problem
Method 1
var isPalindrome = function(x) { let s=x+""; let result=[]; for(let i=s.length-1;i>=0;i--){ result.push(s[i]); } if(s==result.join("")){ return true; } else{ return false; } };Method 2
var isPalindrome = function(x) { return x.toString()==x.toString().split('').reverse().join(''); };
边栏推荐
- 奥比中光 astra: Could not open “2bc5/[email protected]/6“: Failed to set USB interface
- Comparison between rstan Bayesian regression model and standard linear regression model of R language MCMC
- Review materials for the special topic of analog electronics with all essence: basic amplification circuit knowledge points
- Best practices for building multi architecture images
- End time processing method of wechat v3native payment settings
- Fiddler realizes mobile packet capturing - getting started
- Make p12 certificate [easy to understand]
- Pattern matching extraction of specific subgraphs in graphx graph Computing Practice
- [Xiaobai chat cloud] suggestions on container transformation of small and medium-sized enterprises
- Experiment collection of University "Fundamentals of circuit analysis". Experiment 4 - Research on linear circuit characteristics
猜你喜欢

《大学“电路分析基础”课程实验合集.实验七》丨正弦稳态电路的研究

Processing gzip: stdin: not in gzip format: child returned status 1tar: error is not recoverable: exitin

Aiko ai Frontier promotion (7.2)

How to import a billion level offline CSV into Nepal graph

《大学“电路分析基础”课程实验合集.实验五》丨线性有源二端网络等效电路的研究
![[5g NR] RRC connection release](/img/f3/a03f5124493b1c03e7336c55871330.png)
[5g NR] RRC connection release

XPT2046 四线电阻式触摸屏

Add user-defined formula (time sharing t+0) to mobile app access as an example

Idea public method extraction shortcut key

Introduction to Dynamic Planning II (5.647.62)
随机推荐
beforeEach
Use ffmpeg command line to push UDP and RTP streams (H264 and TS), and ffplay receives
End time processing method of wechat v3native payment settings
Boot 事务使用
Song of cactus - throwing stones to ask the way (3)
Ant group's large-scale map computing system tugraph passed the national evaluation
Ssh/scp does not prompt all activities are monitored and reported
Pyinstaller打包exe附带图片的方法
Analysis of the difference between array and linked list
死锁的条件及解决方法
数组和链表的区别浅析
多数据源配置代码
How to use percona tool to add fields to MySQL table after interruption
Comprehensively interpret the background and concept of service mesh
2020.4.12 byte written test questions B DP D monotone stack
PyObject 转 char* (string)
Flink real-time data warehouse (IX): incremental synchronization of data in MySQL
C # get PLC information (kepserver) II
制作p12证书[通俗易懂]
如何實現十億級離線 CSV 導入 Nebula Graph