LeetCode Palindrome Number
Problem Description Link: https://leetcode.com/problems/palindrome-number/
Accepted Solution
/*
The solution is easy, and I believe everyone knows the process. However, one problem is that x is a number. If it is a string, in that case, we can get the result after reversing it. Therefore, to solve the problem, we have to find the digits by modulating 10, store them in an array, and finally compare from both sides. If we find any discrepancy, we can tell it is not a palindrome. Note that any negative integer would never be a palindrome since it should contain a minus (-) sign.
*/
Comments
Post a Comment