Leetcode, Scala, Palindrome Number, Programming, Technical Interview.
var revertedNumber = 0 var y = x // Step 2: Revert the second half of the number while (y > revertedNumber) { revertedNumber = revertedNumber * 10 + y % 10 y /= 10 } // Step 3: Check if halves are equal y == revertedNumber || y == revertedNumber / 10 } } Step 1: Exclude negative numbers and numbers