Solving A Leetcode problem Day-3/10

Solving A Leetcode problem Day-3/10

Question 9 - Palindrome Number- Easy

Today is day 3 of the #14G10daysofcode challenge given by Ingressive4good. Today we are given a pretty simple question on leetcode. Palindrome Number (Difficulty - Easy)

Question

Given an integer x, return true if x is palindrome integer.

An integer is a palindrome when it reads the same backward as forward.

For example, 121 is a palindrome while 123 is not.

An example

Input: x = 121
Output: true
Explanation: 121 reads as 121 from left to right and from right to left.

In my opinion , this is a very simple task. I decide to dive into php to solve this problem (been using js for a while tho!).

My approach

-First i converted the numbers to string using php inbuilt function strval( ) . -Next i reversed the string using another inbuilt function strrev( )

That's probably why i decided the language to be php lol!

Next i compared the result gotten from step 1 and 2 with the original integer that was provided,then returned the result of that comparison.

Straightforward and simple! Right?

Screenshot (142).png

Well that's all for now, if this blog post was any useful to you , Please give it a thumbs up.

You can also follow me on Twitter and Linkedin