Determine whether a given integer is a palindrome or not. Do this without extra space.
Note that the negative integers are assumed to be non-palindromic. Also, you are not allowed to convert the integer to string, given the restriction of using extra space.
Approach:
Return false if the given integer is negative. Otherwise, reverse the given integer and return true if the reversed integer and the given integer are both same else false.
Here is the link to ideone solution : http://ideone.com/9YyJke
0 comments:
Post a Comment