{"id":29,"date":"2024-09-23T23:07:10","date_gmt":"2024-09-23T15:07:10","guid":{"rendered":"https:\/\/blog.zeronely.cn\/?p=29"},"modified":"2024-09-30T12:20:14","modified_gmt":"2024-09-30T04:20:14","slug":"%e5%88%b7%e9%a2%98%e5%91%a8%e8%ae%b0%ef%bc%881%ef%bc%89","status":"publish","type":"post","link":"https:\/\/blog.zeronely.cn\/index.php\/2024\/09\/23\/%e5%88%b7%e9%a2%98%e5%91%a8%e8%ae%b0%ef%bc%881%ef%bc%89\/","title":{"rendered":"\u5237\u9898\u5468\u8bb0\uff081\uff09\u2014\u201449.\u5b57\u6bcd\u5f02\u4f4d\u8bcd\u5206\u7ec4"},"content":{"rendered":"\n<p>\u601d\u8def\u5206\u6790\uff1a\u9996\u5148\uff0c\u601d\u8003\u5982\u4f55\u5224\u65ad\u201c\u5f02\u4f4d\u8bcd\u201d\uff0c\u76f4\u89c2\u7684\u60f3\u5230\uff0c\u5c06string\u5185\u90e8\u6309\u7167\u5b57\u6bcd\u5e8f\u6392\u5e8f\uff0c\u4e4b\u540e\u4fbf\u53ef\u4ee5\u76f4\u63a5\u5bf9\u6bd4\uff0c\u6392\u5e8f\u540e\u76f8\u7b49\u7684string\u5c31\u662f\u5f02\u4f4d\u8bcd\u3002\u5176\u6b21\uff0c\u60f3\u5230\u53ef\u4ee5\u5229\u7528\u54c8\u5e0c\u8868\u6765\u8fdb\u884c\u5b57\u7b26\u4e32vector\u7684\u5b58\u50a8\uff08\u5373\u4e00\u4e2a\u6392\u5e8f\u6210\u529f\u7684key\uff0c\u5bf9\u5e94\u4e00\u7ec4string\uff09<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>49.\u5b57\u6bcd\u5f02\u4f4d\u8bcd\u5206\u7ec4<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>class Solution {\npublic:\n    vector&lt;vector&lt;string>> groupAnagrams(vector&lt;string>&amp; strs) {\n        unordered_map&lt;string, vector&lt;string>> mp;\n        for (string&amp; str: strs) {\n            string key = str;\n            sort(key.begin(), key.end());\/\/\u5bf9str\u7684\u526f\u672ckey\u8fdb\u884c\u6392\u5e8f\uff0c\u5f62\u6210\u201c\u7279\u5f81\u201d\uff0c\u7528\u4e8e\u201c\u5206\u7c7b\u201d\n            mp&#91;key].emplace_back(str);\n        }\n        vector&lt;vector&lt;string>> ans;\n        for (auto it = mp.begin(); it != mp.end(); ++it) {\n            ans.emplace_back(it->second);\/\/\u5c06\u6309\u7167\u6392\u5e8f\u540estring\u5206\u5b8c\u7c7b\u7684vector\u538b\u5165\u4e8c\u7ef4vector\n        }\n        return ans;\n    }\n};<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u601d\u8def\u5206\u6790\uff1a\u9996\u5148\uff0c\u601d\u8003\u5982\u4f55\u5224\u65ad\u201c\u5f02\u4f4d\u8bcd\u201d\uff0c\u76f4\u89c2\u7684\u60f3\u5230\uff0c\u5c06string\u5185\u90e8\u6309\u7167\u5b57\u6bcd\u5e8f\u6392\u5e8f\uff0c\u4e4b\u540e\u4fbf\u53ef\u4ee5\u76f4\u63a5\u5bf9\u6bd4\uff0c\u6392\u5e8f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,3],"tags":[9],"class_list":["post-29","post","type-post","status-publish","format-standard","hentry","category-leetcode","category-3","tag-leetcode"],"_links":{"self":[{"href":"https:\/\/blog.zeronely.cn\/index.php\/wp-json\/wp\/v2\/posts\/29","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.zeronely.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.zeronely.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.zeronely.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.zeronely.cn\/index.php\/wp-json\/wp\/v2\/comments?post=29"}],"version-history":[{"count":2,"href":"https:\/\/blog.zeronely.cn\/index.php\/wp-json\/wp\/v2\/posts\/29\/revisions"}],"predecessor-version":[{"id":35,"href":"https:\/\/blog.zeronely.cn\/index.php\/wp-json\/wp\/v2\/posts\/29\/revisions\/35"}],"wp:attachment":[{"href":"https:\/\/blog.zeronely.cn\/index.php\/wp-json\/wp\/v2\/media?parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.zeronely.cn\/index.php\/wp-json\/wp\/v2\/categories?post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.zeronely.cn\/index.php\/wp-json\/wp\/v2\/tags?post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}