{"id":5398,"date":"2023-11-19T10:22:00","date_gmt":"2023-11-19T02:22:00","guid":{"rendered":"https:\/\/white-night.club\/?p=5398"},"modified":"2023-11-19T10:22:48","modified_gmt":"2023-11-19T02:22:48","slug":"ad157","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/11\/19\/ad157\/","title":{"rendered":"58.\u00a0\u6700\u540e\u4e00\u4e2a\u5355\u8bcd\u7684\u957f\u5ea6"},"content":{"rendered":"\n<p>\u7ed9\u4f60\u4e00\u4e2a\u5b57\u7b26\u4e32&nbsp;<code>s<\/code>\uff0c\u7531\u82e5\u5e72\u5355\u8bcd\u7ec4\u6210\uff0c\u5355\u8bcd\u524d\u540e\u7528\u4e00\u4e9b\u7a7a\u683c\u5b57\u7b26\u9694\u5f00\u3002\u8fd4\u56de\u5b57\u7b26\u4e32\u4e2d&nbsp;<strong>\u6700\u540e\u4e00\u4e2a<\/strong>&nbsp;\u5355\u8bcd\u7684\u957f\u5ea6\u3002<\/p>\n\n\n\n<p><strong>\u5355\u8bcd<\/strong>&nbsp;\u662f\u6307\u4ec5\u7531\u5b57\u6bcd\u7ec4\u6210\u3001\u4e0d\u5305\u542b\u4efb\u4f55\u7a7a\u683c\u5b57\u7b26\u7684\u6700\u5927\u5b50\u5b57\u7b26\u4e32\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><strong>\u8f93\u5165\uff1a<\/strong>s = &#8220;Hello World&#8221; <strong>\u8f93\u51fa\uff1a<\/strong>5 <strong>\u89e3\u91ca\uff1a<\/strong>\u6700\u540e\u4e00\u4e2a\u5355\u8bcd\u662f\u201cWorld\u201d\uff0c\u957f\u5ea6\u4e3a5\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><strong>\u8f93\u5165\uff1a<\/strong>s = &#8221; fly me to the moon &#8221; <strong>\u8f93\u51fa\uff1a<\/strong>4<strong> \u89e3\u91ca\uff1a<\/strong>\u6700\u540e\u4e00\u4e2a\u5355\u8bcd\u662f\u201cmoon\u201d\uff0c\u957f\u5ea6\u4e3a4\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 3\uff1a<\/strong><strong>\u8f93\u5165\uff1a<\/strong>s = &#8220;luffy is still joyboy&#8221; <strong>\u8f93\u51fa\uff1a<\/strong>6 <strong>\u89e3\u91ca\uff1a<\/strong>\u6700\u540e\u4e00\u4e2a\u5355\u8bcd\u662f\u957f\u5ea6\u4e3a6\u7684\u201cjoyboy\u201d\u3002<\/p>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li><code>1 &lt;= s.length &lt;= 10<sup>4<\/sup><\/code><\/li>\n\n\n\n<li><code>s<\/code>&nbsp;\u4ec5\u6709\u82f1\u6587\u5b57\u6bcd\u548c\u7a7a\u683c&nbsp;<code>' '<\/code>&nbsp;\u7ec4\u6210<\/li>\n\n\n\n<li><code>s<\/code>&nbsp;\u4e2d\u81f3\u5c11\u5b58\u5728\u4e00\u4e2a\u5355\u8bcd<\/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 has-link-color wp-elements-f39840ab6d22df5eca927d18e00896d0\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>\u5224\u65ad\u5b57\u6bcd<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u4e00\u5f00\u59cb\u6392\u9664\u5c3e\u90e8\u7a7a\u683c\u7684\u65f6\u5019\u6ca1\u5199break\uff0c\u6211\u8bf4\u600e\u4e48\u7b97\u51fa\u6765\u4e0d\u5bf9\u634f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>func lengthOfLastWord(s string) int {\r\n    size:=len(s)\r\n    result:=0\r\n    for right:=size-1;right>=0;right--{\r\n        if s&#91;right]==' '{\r\n            size--\r\n        }else{\r\n            break\r\n        }\r\n    }\r\n    for right:=size-1;right>=0;right--{\r\n        if s&#91;right]>='A'&amp;&amp;s&#91;right]&lt;='Z'||s&#91;right]>='a'&amp;&amp;s&#91;right]&lt;='z'{\r\n            result++\r\n        }else if s&#91;right]==' '{\r\n            break\r\n        }\r\n    }\r\n    return result\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u5224\u65ad\u5b57\u6bcd<\/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\/5398"}],"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=5398"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/5398\/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=5398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=5398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=5398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}