Palindrome Number
Given an integer x, return true if x is a palindrome, and false otherwise.
Solution, Typescript
function isPalindrome(x: number): boolean {if(x < 0) {return false;}let remainder = x;let placeValue = 1;let val = 0;while(remainder > 0) {let digit = remainder % 10;val = val * 10 + digit;if(val > x) {return false;}remainder = Math.trunc(remainder / 10);}return val === x;};
I totally one shot submitted this and was surprised it worked. 😈ðŸ¤