分类: Java
2015-01-21 10:20:21
Could negative integers be palindromes? (ie, -1)
If you are thinking of converting the integer to string, note the restriction of using extra space.
You could also try reversing an integer. However, if you have solved the problem "Reverse Integer", you know that the reversed integer might overflow. How would you handle such case?
There is a more generic way of solving this problem.
解决思路:题目要求不能使用额外的空间,那么转换成string然后按照判断字符串的方法来判断是否为回文数应该是不可行的,应此解决方法如下:
点击(此处)折叠或打开