字符串整数的余数leetcode-isPalindrome:判断一个int是否是回文的java实现

时间:2024-07-20 05:20:54
【文件属性】:

文件名称:字符串整数的余数leetcode-isPalindrome:判断一个int是否是回文的java实现

文件大小:4KB

文件格式:ZIP

更新时间:2024-07-20 05:20:54

系统开源

字符串可能的余数是回文 判断一个int是否是回文的java实现 判断一个整数是否是回文。 当一个整数向后读与向前读相同时,它就是回文。 示例 1: Input: 121 Output: true 示例 2: Input: -121 Output: false 说明:从左到右依次为 -121。 从右到左,它变成 121-。 因此它不是回文。 示例 3: Input: 10 Output: false 说明:从右到左读取 01。 因此它不是回文。 第一个想法: - 0 is a palindrome. - All negative integers are not. - All numbers that end with a 0 are not (multiples of 10) - If the number was a string, and if the reserved string is equal to the original, then the number is a palindrome. 第一种解决方案,使用 StringBuilder 反向方法: public boo


【文件预览】:
isPalindrome-master
----palindromeInteger.java(2KB)
----mathOnlyStrategy.java(374B)
----SolutionStrategy.java(71B)
----stringBuilderReverseStrategy.java(245B)
----.gitignore(909B)
----charArrayStrategy.java(330B)
----README.md(2KB)

网友评论