Palindrome 回文数
回文数,从前到后,从后到前都一样
把数字转成字符串来处理
package com.rust.cal; public class Palindrome { public static boolean isPalindrome(int x) { String s = String.valueOf(x); String revers = new StringBuffer(s).reverse().toString(); if (s.equalsIgnoreCase(revers)) { return true; } return false; } public static void main(String arg[]){ int input = 123; if (isPalindrome(input)) { System.out.println("Yes"); } else { System.out.println("NO"); } } }
Palindrome 回文数的更多相关文章
- leetcode4 Valid Palindrome回文数
Valid Palindrome回文数 whowhoha@outlook.com Question: Given a string, determine if it is a palindrome, ...
- 有趣的数-回文数(Palindrome number)
文章转自http://blog.163.com/hljmdjlln@126/blog/static/5473620620120412525181/ 做LC上的题"Palindrome num ...
- Leetcode 3——Palindrome Number(回文数)
Problem: Determine whether an integer is a palindrome. Do this without extra space. 简单的回文数,大一肯定有要求写过 ...
- leetcode 9 Palindrome Number 回文数
Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. S ...
- palindrome number(回文数)
Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negativ ...
- [LeetCode] Prime Palindrome 质数回文数
Find the smallest prime palindrome greater than or equal to N. Recall that a number is prime if it's ...
- [Swift]LeetCode9. 回文数 | Palindrome Number
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same back ...
- [Swift]LeetCode479. 最大回文数乘积 | Largest Palindrome Product
Find the largest palindrome made from the product of two n-digit numbers. Since the result could be ...
- [Swift]LeetCode564. 寻找最近的回文数 | Find the Closest Palindrome
Given an integer n, find the closest integer (not including itself), which is a palindrome. The 'clo ...
随机推荐
- java中File类中list()和listFiles()方法区别
list()和listFiles()方法区别: 1.返回值类型不同:前者为String数组,后者为File对象数组 2.数组中元素内容不同:前者为string类型的[文件名](包含后缀名),后者为Fi ...
- Android高效内存1:一张图片占用多少内存
在做内存优化的时候,我们发现除了解决内存泄露问题,剩下的就只有想办法减少真实的内存占用.而在App中,大部分内存可能被我们图片占用了,所以减少图片的内存占用可以带来直接的效果.本文就简单介绍一张图片到 ...
- IntelliJ IDEA 2017.1.4 x64配置说明
只是为了研究下idea这款编译器怎么使用.开门见山,说下如何配置这款编译器,不配置也能用,但是强迫症表示不服.下面直入正题: 下载与安装就不说了,除了更改安装目录外,没啥注意的地方,建议下载idea去 ...
- linux切换g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 50(优先级) sudo update-alternative ...
- awk内引用shell变量【自己手动加精】
题目 [root@localhost ~]# cat 1.txt iii sss ddd 执行命令 [root@localhost ~]# A=0 [root@localhost ~]# awk '{ ...
- [转]html转码表
为什么要用转义字符串? HTML中<,>,&等有特殊含义(<,>,用于链接签,&用于转义),不能直接使用.这些符号是不显示在我们最终看到的网页里的,那如果我们希 ...
- os模块学习小随笔
os模块为python解释器与操作系统交互的接口 os.popen() -------Open a pipe to or from command. The return value is an ...
- Vulkan Tutorial 18 重构交换链
操作系统:Windows8.1 显卡:Nivida GTX965M 开发工具:Visual Studio 2017 Introduction 现在我们已经成功的在屏幕上绘制出三角形,但是在某些情况下, ...
- 添加OpenStack Mitaka源
sudo apt-get install ubuntu-cloud-keyring sudo add-apt-repository cloud-archive:mitaka 同理,可以添加其它版本,如 ...
- 【转载】QT QTableView用法小结
原始日期: 2016-08-16 09:28 来源:http://blog.csdn.net/wang_lichun/article/details/7805253 QTableView常用于实现数据 ...