{"id":5472,"date":"2023-11-20T13:53:34","date_gmt":"2023-11-20T05:53:34","guid":{"rendered":"https:\/\/white-night.club\/?p=5472"},"modified":"2023-11-20T13:53:52","modified_gmt":"2023-11-20T05:53:52","slug":"ad160","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/11\/20\/ad160\/","title":{"rendered":"2351.\u00a0\u7b2c\u4e00\u4e2a\u51fa\u73b0\u4e24\u6b21\u7684\u5b57\u6bcd"},"content":{"rendered":"\n<p>\u7ed9\u4f60\u4e00\u4e2a\u7531\u5c0f\u5199\u82f1\u6587\u5b57\u6bcd\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\u00a0<code>s<\/code>\u00a0\uff0c\u8bf7\u4f60\u627e\u51fa\u5e76\u8fd4\u56de\u7b2c\u4e00\u4e2a\u51fa\u73b0\u00a0<strong>\u4e24\u6b21<\/strong>\u00a0\u7684\u5b57\u6bcd\u3002<\/p>\n\n\n\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li>\u5982\u679c&nbsp;<code>a<\/code>&nbsp;\u7684&nbsp;<strong>\u7b2c\u4e8c\u6b21<\/strong>&nbsp;\u51fa\u73b0\u6bd4&nbsp;<code>b<\/code>&nbsp;\u7684&nbsp;<strong>\u7b2c\u4e8c\u6b21<\/strong>&nbsp;\u51fa\u73b0\u5728\u5b57\u7b26\u4e32\u4e2d\u7684\u4f4d\u7f6e\u66f4\u9760\u524d\uff0c\u5219\u8ba4\u4e3a\u5b57\u6bcd&nbsp;<code>a<\/code>&nbsp;\u5728\u5b57\u6bcd&nbsp;<code>b<\/code>&nbsp;\u4e4b\u524d\u51fa\u73b0\u4e24\u6b21\u3002<\/li>\n\n\n\n<li><code>s<\/code>&nbsp;\u5305\u542b\u81f3\u5c11\u4e00\u4e2a\u51fa\u73b0\u4e24\u6b21\u7684\u5b57\u6bcd\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><strong>\u8f93\u5165\uff1a<\/strong>s = &#8220;abccbaacz&#8221; <strong>\u8f93\u51fa\uff1a<\/strong>&#8220;c&#8221; <strong>\u89e3\u91ca\uff1a<\/strong> \u5b57\u6bcd &#8216;a&#8217; \u5728\u4e0b\u6807 0 \u30015 \u548c 6 \u5904\u51fa\u73b0\u3002 \u5b57\u6bcd &#8216;b&#8217; \u5728\u4e0b\u6807 1 \u548c 4 \u5904\u51fa\u73b0\u3002 \u5b57\u6bcd &#8216;c&#8217; \u5728\u4e0b\u6807 2 \u30013 \u548c 7 \u5904\u51fa\u73b0\u3002 \u5b57\u6bcd &#8216;z&#8217; \u5728\u4e0b\u6807 8 \u5904\u51fa\u73b0\u3002 \u5b57\u6bcd &#8216;c&#8217; \u662f\u7b2c\u4e00\u4e2a\u51fa\u73b0\u4e24\u6b21\u7684\u5b57\u6bcd\uff0c\u56e0\u4e3a\u5728\u6240\u6709\u5b57\u6bcd\u4e2d\uff0c&#8217;c&#8217; \u7b2c\u4e8c\u6b21\u51fa\u73b0\u7684\u4e0b\u6807\u662f\u6700\u5c0f\u7684\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><strong>\u8f93\u5165\uff1a<\/strong>s = &#8220;abcdd&#8221; <strong>\u8f93\u51fa\uff1a<\/strong>&#8220;d&#8221; <strong>\u89e3\u91ca\uff1a<\/strong> \u53ea\u6709\u5b57\u6bcd &#8216;d&#8217; \u51fa\u73b0\u4e24\u6b21\uff0c\u6240\u4ee5\u8fd4\u56de &#8216;d&#8217; \u3002<\/p>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li><code>2 &lt;= s.length &lt;= 100<\/code><\/li>\n\n\n\n<li><code>s<\/code>&nbsp;\u7531\u5c0f\u5199\u82f1\u6587\u5b57\u6bcd\u7ec4\u6210<\/li>\n\n\n\n<li><code>s<\/code>&nbsp;\u5305\u542b\u81f3\u5c11\u4e00\u4e2a\u91cd\u590d\u5b57\u6bcd<\/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-77d9babb6403b76b85ed1ff0e704a074\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>\u54c8\u5e0c\u8868<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u4e3b\u8981\u662fgo\u91cc\u9762map\u7684\u4e00\u4e2a\u7528\u6cd5\u3002\u8bdd\u8bf4go\u4e3a\u5565\u4e0d\u7528char\u800c\u662f\u7528byte\/rune\uff0c\u8fd8\u86ee\u597d\u5947\u7684\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>func repeatedCharacter(s string) byte {\r\n    hashmap:=make(map&#91;byte]int,26)\r\n    for i:=0;i&lt;len(s);i++{\r\n        if _,ok:=hashmap&#91;s&#91;i]-'a'];ok{\r\n            hashmap&#91;s&#91;i]-'a']++\r\n        }else{\r\n            hashmap&#91;s&#91;i]-'a']++\r\n        }\r\n        if hashmap&#91;s&#91;i]-'a']>=2{\r\n            return s&#91;i]\r\n        }\r\n    }\r\n    return s&#91;0]\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u54c8\u5e0c\u8868<\/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\/5472"}],"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=5472"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/5472\/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=5472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=5472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=5472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}