Leetcode PHP solution — d133 9 Palindrome Number


D133 9. Palindrome Number

Title Link

9. Palindrome Number

Topic analysis

This question is very simple. It is to judge whether a given number is a palindrome number. The palindrome number is the same as reading from left to right.

But this question is slightly different from question 7, and the symbols should be the same.

Problem solving ideas

The symbols should also be consistent, which is simple. Directly flip it with the strrev function, and then judge whether it is equal to the original content.

Final code

class Solution {

     * @param Integer $x
     * @return Boolean
    function isPalindrome($x) {
        return $x == strrev($x);

If you think this article is useful to you, you are welcome to use love power generation.

Recommended Today

Spring source code analysis II: context component (webapplicationcontext)

Spring source code analysis II: context component (webapplicationcontext) The last article analyzedDispatcherServletAndContextLoaderListenerThese two classes resolve the process of application initialization and request processing, but some components need to be resolved: ConfigurableWebApplicationContext.refreshRefresh context ApplicationContext.getBeanGet bean from context DispatcherServlet.propertiesPolicy processing defined in the file ContextLoader.propertiesPolicy processing defined in the file View.renderView rendering Let’s take a look at […]