{"id":1735,"date":"2022-01-10T15:12:51","date_gmt":"2022-01-10T07:12:51","guid":{"rendered":"http:\/\/139.9.1.231\/?p=1735"},"modified":"2022-01-10T15:12:52","modified_gmt":"2022-01-10T07:12:52","slug":"leetcodeday9","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/10\/leetcodeday9\/","title":{"rendered":"leetcodeday9 &#8211;\u56de\u6587\u6570"},"content":{"rendered":"\n<p>\u7ed9\u4f60\u4e00\u4e2a\u6574\u6570&nbsp;<code>x<\/code>&nbsp;\uff0c\u5982\u679c&nbsp;<code>x<\/code>&nbsp;\u662f\u4e00\u4e2a\u56de\u6587\u6574\u6570\uff0c\u8fd4\u56de&nbsp;<code>true<\/code>&nbsp;\uff1b\u5426\u5219\uff0c\u8fd4\u56de&nbsp;<code>false<\/code>&nbsp;\u3002<\/p>\n\n\n\n<p>\u56de\u6587\u6570\u662f\u6307\u6b63\u5e8f\uff08\u4ece\u5de6\u5411\u53f3\uff09\u548c\u5012\u5e8f\uff08\u4ece\u53f3\u5411\u5de6\uff09\u8bfb\u90fd\u662f\u4e00\u6837\u7684\u6574\u6570\u3002\u4f8b\u5982\uff0c<code>121<\/code>&nbsp;\u662f\u56de\u6587\uff0c\u800c&nbsp;<code>123<\/code>&nbsp;\u4e0d\u662f\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>x = 121\n<strong>\u8f93\u51fa\uff1a<\/strong>true<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b&nbsp;2\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>x = -121\n<strong>\u8f93\u51fa\uff1a<\/strong>false\n<strong>\u89e3\u91ca\uff1a<\/strong>\u4ece\u5de6\u5411\u53f3\u8bfb, \u4e3a -121 \u3002 \u4ece\u53f3\u5411\u5de6\u8bfb, \u4e3a 121- \u3002\u56e0\u6b64\u5b83\u4e0d\u662f\u4e00\u4e2a\u56de\u6587\u6570\u3002<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 3\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>x = 10\n<strong>\u8f93\u51fa\uff1a<\/strong>false\n<strong>\u89e3\u91ca\uff1a<\/strong>\u4ece\u53f3\u5411\u5de6\u8bfb, \u4e3a 01 \u3002\u56e0\u6b64\u5b83\u4e0d\u662f\u4e00\u4e2a\u56de\u6587\u6570\u3002<\/code><\/pre>\n\n\n\n<p>\u9996\u5148\u6211\u60f3\u7684\u662f\u5b57\u7b26\u4e32\u65b9\u6cd5\uff1a\u53ea\u8981\u5224\u65ad\u9996\u5c3e\u90e8\u7684\u5b57\u7b26\u662f\u5426\u76f8\u540c\u5c31\u53ef<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># @lc code=start\r\nclass Solution:\r\n    def isPalindrome(self, x: int) -> bool:\r\n        s=str(x)\r\n        length=len(s)\r\n        i=0\r\n        while i&lt;=length-1:\r\n            if s&#91;i]==s&#91;length-1]:\r\n                \r\n               i=i+1\r\n               length=length-1\r\n            else:\r\n                return False\r\n        return True\r\n\r\n# @lc code=end\r\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"777\" height=\"150\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-169.png\" alt=\"\" class=\"wp-image-1737\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-169.png 777w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-169-300x58.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-169-768x148.png 768w\" sizes=\"(max-width: 777px) 100vw, 777px\" \/><\/figure>\n\n\n\n<p><strong>\u8fdb\u9636\uff1a<\/strong>\u4f60\u80fd\u4e0d\u5c06\u6574\u6570\u8f6c\u4e3a\u5b57\u7b26\u4e32\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u5417\uff1f<\/p>\n\n\n\n<p>\u7b2c\u4e00\u60f3\u6cd5\u662f\u53cd\u8f6c\u6570\u5b57\uff0c\u5224\u65ad\u4e24\u4e2a\u6570\u5b57\u662f\u5426\u4e00\u81f4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># @lc code=start\r\nclass Solution:\r\n    def isPalindrome(self, x: int) -> bool:\r\n        y=x\r\n        if x&lt;0: \r\n            return False\r\n        rev=0\r\n        while x\/\/10>0:\r\n            rev=rev*10+x%10\r\n            x=x\/\/10\r\n        rev=rev*10+x\r\n        return rev==y<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"860\" height=\"151\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-170.png\" alt=\"\" class=\"wp-image-1738\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-170.png 860w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-170-300x53.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-170-768x135.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/figure>\n\n\n\n<p>\u4f46\u662f\uff0c\u5982\u679c\u53cd\u8f6c\u540e\u7684\u6570\u5b57\u5927\u4e8eint.MAX\uff0c\u6211\u4eec\u5c06\u9047\u5230\u6574\u6570\u6ea2\u51fa\u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u6309\u7167\u7b2c\u4e8c\u4e2a\u60f3\u6cd5\uff0c\u4e3a\u4e86\u907f\u514d\u6570\u5b57\u53cd\u8f6c\u53ef\u80fd\u5bfc\u81f4\u7684\u6ea2\u51fa\u95ee\u9898\uff0c\u4e3a\u4ec0\u4e48\u4e0d\u8003\u8651\u53ea\u53cd\u8f6c int \u6570\u5b57\u7684\u4e00\u534a\uff1f\u6bd5\u7adf\uff0c\u5982\u679c\u8be5\u6570\u5b57\u662f\u56de\u6587\uff0c\u5176\u540e\u534a\u90e8\u5206\u53cd\u8f6c\u540e\u5e94\u8be5\u4e0e\u539f\u59cb\u6570\u5b57\u7684\u524d\u534a\u90e8\u5206\u76f8\u540c\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u8f93\u5165 1221\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u6570\u5b57 \u201c1221\u201d \u7684\u540e\u534a\u90e8\u5206\u4ece \u201c21\u201d \u53cd\u8f6c\u4e3a \u201c12\u201d\uff0c\u5e76\u5c06\u5176\u4e0e\u524d\u534a\u90e8\u5206 \u201c12\u201d \u8fdb\u884c\u6bd4\u8f83\uff0c\u56e0\u4e3a\u4e8c\u8005\u76f8\u540c\uff0c\u6211\u4eec\u5f97\u77e5\u6570\u5b57 1221 \u662f\u56de\u6587\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u4f60\u4e00\u4e2a\u6574\u6570&nbsp;x&nbsp;\uff0c\u5982\u679c&nbsp;x&nbsp;\u662f\u4e00\u4e2a\u56de\u6587\u6574\u6570\uff0c\u8fd4\u56de&nbsp;true &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/10\/leetcodeday9\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday9 &#8211;\u56de\u6587\u6570<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/1735"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=1735"}],"version-history":[{"count":2,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/1735\/revisions"}],"predecessor-version":[{"id":1739,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/1735\/revisions\/1739"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=1735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=1735"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=1735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}