Solving the LeetCode Problem Palindrome Number

For this blog I’ll be solving another popular algorithm problem from LeetCode, Palindrome Number. Note that this problem will be solved in JavaScript! I’ll also be demonstrating three ways in which we can solve this problem.

Using Built-In Methods:

Here are the built-in methods that we can use to solve the first step which is reversing the number:

Not Built-In Methods:

I’m aware that I need to have a variable that represents the reversed number. So I created a variable reversed that at the moment will be equal to zero. Similar to the solution with the built-in methods, I would like to also compare reversed with another number so that I can get a boolean value. That’s why I created a variable original which will be equal to num.