{"id":2551,"date":"2023-10-14T11:46:00","date_gmt":"2023-10-14T03:46:00","guid":{"rendered":"https:\/\/white-night.club\/?p=2551"},"modified":"2023-11-09T11:07:50","modified_gmt":"2023-11-09T03:07:50","slug":"ad47","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/14\/ad47\/","title":{"rendered":"125.\u00a0\u9a8c\u8bc1\u56de\u6587\u4e32"},"content":{"rendered":"\n<p>\u5982\u679c\u5728\u5c06\u6240\u6709\u5927\u5199\u5b57\u7b26\u8f6c\u6362\u4e3a\u5c0f\u5199\u5b57\u7b26\u3001\u5e76\u79fb\u9664\u6240\u6709\u975e\u5b57\u6bcd\u6570\u5b57\u5b57\u7b26\u4e4b\u540e\uff0c\u77ed\u8bed\u6b63\u7740\u8bfb\u548c\u53cd\u7740\u8bfb\u90fd\u4e00\u6837\u3002\u5219\u53ef\u4ee5\u8ba4\u4e3a\u8be5\u77ed\u8bed\u662f\u4e00\u4e2a&nbsp;<strong>\u56de\u6587\u4e32<\/strong>&nbsp;\u3002<\/p>\n\n\n\n<p>\u5b57\u6bcd\u548c\u6570\u5b57\u90fd\u5c5e\u4e8e\u5b57\u6bcd\u6570\u5b57\u5b57\u7b26\u3002<\/p>\n\n\n\n<p>\u7ed9\u4f60\u4e00\u4e2a\u5b57\u7b26\u4e32&nbsp;<code>s<\/code>\uff0c\u5982\u679c\u5b83\u662f&nbsp;<strong>\u56de\u6587\u4e32<\/strong>&nbsp;\uff0c\u8fd4\u56de&nbsp;<code>true<\/code><em>&nbsp;<\/em>\uff1b\u5426\u5219\uff0c\u8fd4\u56de<em>&nbsp;<\/em><code>false<\/code><em>&nbsp;<\/em>\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165:<\/strong> s = \"A man, a plan, a canal: Panama\"\n<strong>\u8f93\u51fa\uff1a<\/strong>true\n<strong>\u89e3\u91ca\uff1a<\/strong>\"amanaplanacanalpanama\" \u662f\u56de\u6587\u4e32\u3002\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>s = \"race a car\"\n<strong>\u8f93\u51fa\uff1a<\/strong>false\n<strong>\u89e3\u91ca\uff1a<\/strong>\"raceacar\" \u4e0d\u662f\u56de\u6587\u4e32\u3002\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 3\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>s = \" \"\n<strong>\u8f93\u51fa\uff1a<\/strong>true\n<strong>\u89e3\u91ca\uff1a<\/strong>\u5728\u79fb\u9664\u975e\u5b57\u6bcd\u6570\u5b57\u5b57\u7b26\u4e4b\u540e\uff0cs \u662f\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32 \"\" \u3002\n\u7531\u4e8e\u7a7a\u5b57\u7b26\u4e32\u6b63\u7740\u53cd\u7740\u8bfb\u90fd\u4e00\u6837\uff0c\u6240\u4ee5\u662f\u56de\u6587\u4e32\u3002\n<\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li><code>1 &lt;= s.length &lt;= 2 * 10<sup>5<\/sup><\/code><\/li>\n\n\n\n<li><code>s<\/code>&nbsp;\u4ec5\u7531\u53ef\u6253\u5370\u7684 ASCII \u5b57\u7b26\u7ec4\u6210<\/li>\n<\/ul>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>\u76f8\u5173\u51fd\u6570\u7684\u8c03\u7528<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u6211\u7528\u7684\u53cc\u6307\u9488\uff0c\u867d\u7136\u5b98\u65b9\u76f4\u63a5\u662f\u8c03\u7528api\u53bb\u505a\u7684&#8230;<\/p>\n\n\n\n<p>\u4e0d\u8fc7\u5373\u4f7f\u662f\u53cc\u6307\u9488\u4e5f\u6ca1\u6709\u4ec0\u4e48\u96be\u70b9\u3002\u4e3b\u8981\u5c31\u662f\u8c03\u7528\u51e0\u4e2aAPI\uff1a<\/p>\n\n\n\n<ul>\n<li>isalnum()\uff1a\u5224\u65ad\u662f\u5426\u4e3a\u82f1\u6587\u5b57\u6bcd\u6216\u6570\u5b57<\/li>\n\n\n\n<li>tolower()\uff1a\u5c06\u5b57\u7b26\u8f6c\u6362\u4e3a\u5c0f\u5199\uff0c\u5982\u679c\u65e0\u6cd5\u8f6c\u6362\u5219\u4fdd\u6301\u539f\u5b57\u7b26\u4e0d\u53d8<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>class Solution {\r\npublic:\r\n    bool isPalindrome(string s) {\r\n        string str;\r\n        for(int i=0;i&lt;s.length();i++)\r\n            if(isalnum(s&#91;i]))\r\n                str+=tolower(s&#91;i]);\r\n\r\n        int left=0,right=str.length()-1;\r\n        while(left&lt;right)\r\n        {\r\n            if(str&#91;left]==str&#91;right])\r\n                if(left==right||left==right-1)\r\n                    return true;\r\n                else\r\n                {\r\n                    left++;\r\n                    right--;\r\n                }\r\n            else\r\n                return false;\r\n           \r\n        }\r\n       return true;\r\n    }\r\n};<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1astr\u76f8\u5173API<\/p>\n","protected":false},"author":1,"featured_media":2827,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[42,25],"tags":[38],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2551"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=2551"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2551\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/2827"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=2551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}