Palindrome Number
程序员文章站
2024-03-22 14:26:04
...
Swift 4.2
class Solution {
func isPalindrome(_ x: Int) -> Bool {
if x < 0 {
return false
}
var originX = x
var reverserdX = 0
while originX > 9 {
reverserdX = (reverserdX + originX % 10) * 10
originX = originX / 10
}
reverserdX += originX % 10
return x == reverserdX
}
}
上一篇: C++必备基础知识(x+1) -《Effective C++必懂条款2》
下一篇: 数组的多数元素
推荐阅读
-
Palindrome Number
-
Palindrome Number
-
rank over partition dense_rank() row_number() SQLOracleCC++C#
-
rank over partition dense_rank() row_number() SQLOracleCC++C#
-
change delicate server max player numbers HOW-TOs 博客分类: UnrealEngine4 what is the maximum number of players UE4 can handle?
-
java.sql.SQLException: Parameter index out of range (1 > number of parameters, w 博客分类: java细节
-
【NOIP提高A组模拟2018.8.18】 number
-
【数位DP】JZOJ 5831. 【NOIP提高A组模拟2018.8.18】 number
-
JS Number类型的数值转换
-
Happy Number 博客分类: Leetcode 哈希