{"id":3754,"date":"2023-10-29T17:17:45","date_gmt":"2023-10-29T09:17:45","guid":{"rendered":"https:\/\/white-night.club\/?p=3754"},"modified":"2023-11-09T11:07:45","modified_gmt":"2023-11-09T03:07:45","slug":"ad110","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/29\/ad110\/","title":{"rendered":"1047.\u00a0\u5220\u9664\u5b57\u7b26\u4e32\u4e2d\u7684\u6240\u6709\u76f8\u90bb\u91cd\u590d\u9879"},"content":{"rendered":"\n<p>\u7ed9\u51fa\u7531\u5c0f\u5199\u5b57\u6bcd\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\u00a0<code>S<\/code>\uff0c<strong>\u91cd\u590d\u9879\u5220\u9664\u64cd\u4f5c<\/strong>\u4f1a\u9009\u62e9\u4e24\u4e2a\u76f8\u90bb\u4e14\u76f8\u540c\u7684\u5b57\u6bcd\uff0c\u5e76\u5220\u9664\u5b83\u4eec\u3002<\/p>\n\n\n\n<p>\u5728 S \u4e0a\u53cd\u590d\u6267\u884c\u91cd\u590d\u9879\u5220\u9664\u64cd\u4f5c\uff0c\u76f4\u5230\u65e0\u6cd5\u7ee7\u7eed\u5220\u9664\u3002<\/p>\n\n\n\n<p>\u5728\u5b8c\u6210\u6240\u6709\u91cd\u590d\u9879\u5220\u9664\u64cd\u4f5c\u540e\u8fd4\u56de\u6700\u7ec8\u7684\u5b57\u7b26\u4e32\u3002\u7b54\u6848\u4fdd\u8bc1\u552f\u4e00\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>\"abbaca\"\n<strong>\u8f93\u51fa\uff1a<\/strong>\"ca\"\n<strong>\u89e3\u91ca\uff1a<\/strong>\n\u4f8b\u5982\uff0c\u5728 \"abbaca\" \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5220\u9664 \"bb\" \u7531\u4e8e\u4e24\u5b57\u6bcd\u76f8\u90bb\u4e14\u76f8\u540c\uff0c\u8fd9\u662f\u6b64\u65f6\u552f\u4e00\u53ef\u4ee5\u6267\u884c\u5220\u9664\u64cd\u4f5c\u7684\u91cd\u590d\u9879\u3002\u4e4b\u540e\u6211\u4eec\u5f97\u5230\u5b57\u7b26\u4e32 \"aaca\"\uff0c\u5176\u4e2d\u53c8\u53ea\u6709 \"aa\" \u53ef\u4ee5\u6267\u884c\u91cd\u590d\u9879\u5220\u9664\u64cd\u4f5c\uff0c\u6240\u4ee5\u6700\u540e\u7684\u5b57\u7b26\u4e32\u4e3a \"ca\"\u3002\n<\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ol>\n<li><code>1 &lt;= S.length &lt;= 20000<\/code><\/li>\n\n\n\n<li><code>S<\/code>&nbsp;\u4ec5\u7531\u5c0f\u5199\u82f1\u6587\u5b57\u6bcd\u7ec4\u6210\u3002<\/li>\n<\/ol>\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>Golang\u6808<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u7528C++\u6211\u80fd\u5149\u901f\u5199\u51fa\uff0c\u6bd5\u7adfSTL\u592a\u5f3a\u4e86\u3002\u4f46\u662f\u6362\u5230go\u5c31\u6709\u70b9\u529b\u4e0d\u4ece\u5fc3\u4e86\uff0c\u96be\u53d7\u3002<\/p>\n\n\n\n<p>\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u628a\u5b57\u8282\u5207\u7247\u5f53\u6808\u7528\uff0c\u76f8\u6bd4\u4e8eC++vector\u7684\u5220\u9664\uff08erase\uff09\uff0cgo\u8981\u5220\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u7684\u8bdd\u53ef\u4ee5\u76f4\u63a5\u53d60-size-1\u7684\u5207\u7247\uff0c\u6211\u8bb0\u5f97\u548cpython\u662f\u5dee\u4e0d\u591a\u7684\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>func removeDuplicates(s string) string {\r\n    str:=&#91;]byte{}\r\n    for i:=range s{\r\n        size:=len(str)\r\n        if size>0 &amp;&amp;str&#91;size-1]==s&#91;i]{\r\n            str=str&#91;:size-1]\r\n        }else{\r\n            str=append(str, s&#91;i])\r\n        }\r\n    }\r\n    return string(str)\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u6808<\/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\/3754"}],"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=3754"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3754\/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=3754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=3754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=3754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}