9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.
Some hints: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. 判断一个整数是否是回文数。不能使用额外的空格来做这道题。 一些提示: 负数可以是回文数吗?(比如:-1) 如果你你想把整数转化成字符串,注意不能使用额外空格的限制。 你也可以尝试反转整数。然而,如果你曾解决了问题“LeetCode算法题7.Reverse Integer”,你知道反转整数可能会溢出。你如何控制这种情况。 解决这道题有一个更通用的方法。
你需要完成以下函数: bool isPalindrome(int x) { }
这道题的网址是:“https://leetcode.com/problems/palindrome-number/#/description”
|