当前位置:网站首页>[LeetCode]9. Palindromes thirty-two
[LeetCode]9. Palindromes thirty-two
2022-06-13 00:12:00 【PowerDon】
Determine whether an integer is a palindrome . Palindrome number refers to positive order ( From left to right ) Reverse order ( From right to left ) Read all the same integers .
Example 1:
Input : 121
Output : true
Example 2:
Input : -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 : 10
Output : false
explain : Read right to left , by 01 . So it's not a palindrome number .
Advanced :
Can you solve this problem without converting integers into strings ?
source : Power button (LeetCode)
link :https://leetcode-cn.com/problems/palindrome-number
Copyright belongs to the network . For commercial reprint, please contact the official authority , Non-commercial reprint please indicate the source .
public class Solution
{
public bool IsPalindrome(int x)
{
if (x < 0)
{
return false;
}
var str = x.ToString().ToCharArray();
Array.Reverse(str);
var res = string.Join("", str);
return x.ToString().Equals(res);
}
}
边栏推荐
- How to gracefully solve the offset problem of Baidu and Gaode maps in leaflet
- Explain bio, NiO, AIO in detail
- How SAP ui5 uses manifest JSON file defines third-party library dependencies
- Enterprise wechat H5_ Authentication, PC website, enterprise wechat scanning code, authorized login
- Free lottery --- PMP renewal PDU | PMP knowledge map
- leaflet如何优雅的展示重叠点位的气泡窗口
- 3、 Storage system
- Basic operations of dict and set
- C language standard IO, such as printf(), scanf(), etc
- 2022-06-13日报: 图灵奖得主:想要在学术生涯中获得成功,需要注意哪些问题?
猜你喜欢

PLC can also make small games ----- CoDeSys can write small games of guessing numbers

MySQL index

H5時代leaflet中還在用DivIcon?

Divicon est toujours utilisé dans le leaflet de l'ère H5?

ik分词器的安装

Kaust:deyao Zhu | value memory map: a graph structured world model based on off-line reinforcement learning

MySql索引

如何实现OSM地图本地发布并自定义配图

The PMP examination time in March 2022 is set -- "March 27"

leaflet中如何优雅的解决百度、高德地图的偏移问题
随机推荐
How to load 100000 pieces of data in leaflet
Leaflet that supports canvas Path. Dashflow dynamic flow direction line
vs studio_ How to use scanf in 2022
June 11, 2022 diary: Mr. Wang's spring, mixed in
Introduction to business rules service on SAP Business Technology Platform (BTP)
【HCIE论述】RR-A
Masa auth - overall design from the user's perspective
如何让矢量瓦片配图神器maputnik支持 geoserver
June 13, 2022 Daily: Turing prize winner: what should we pay attention to if we want to succeed in our academic career?
PLC也能制作小游戏----Codesys编写猜数字小游戏
Basics of network security (1)
在 Golang 中构建 CRUD 应用程序
How to visit a website
Is divicon still used in leaflet in H5 era?
How SAP ui5 uses manifest JSON file defines third-party library dependencies
SAP Business Technology Platform (BTP) workflow function introduction
Accelerating with Dali modules
H5时代leaflet中还在用DivIcon?
[C] Inverts the binary of a decimal number and outputs it
电商员工离职后将产品价格改为1折出售,已被刑拘