Leetcode, Scala, Palindrome Number, Programming, Technical Interview.
negative numbers if (x < 0) return false var original = x var reversed = 0 // Step 2: Reverse the number mathematically while (original != 0) { reversed = reversed * 10 + original % 10 original /= 10 } // Step 3: Compare the original and reversed numbers x == reversed } } Step 1: Rule out negative