{"id":1839,"date":"2016-02-17T21:03:53","date_gmt":"2016-02-17T13:03:53","guid":{"rendered":"http:\/\/boweihe.me\/?p=1839"},"modified":"2016-02-17T21:03:53","modified_gmt":"2016-02-17T13:03:53","slug":"leetcode-242-valid-anagram","status":"publish","type":"post","link":"https:\/\/dayandcarrot.space\/?p=1839","title":{"rendered":"LeetCode 242. Valid Anagram"},"content":{"rendered":"<p><strong>\u539f\u9898\uff1a<\/strong><a href=\"https:\/\/leetcode.com\/problems\/valid-anagram\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/leetcode.com\/problems\/valid-anagram\/<\/a><br \/>\n<strong>\u601d\u8def\uff1a<\/strong>Anagram\u5c31\u662f\u6307\u4e24\u4e2a\u5355\u8bcd\uff08\u4e00\u8bf4\u53e5\u5b50\u4e5f\u884c\uff09\u91cc\u9762\u5b57\u7b26\u7684\u79cd\u7c7b\u3001\u6570\u91cf\u4e00\u6837\uff0c\u4f46\u662f\u80fd\u62fc\u51fa\u4e0d\u540c\u7684\u8bcd\u3002\u6240\u4ee5\u601d\u8def\u5c31\u662f\u7edf\u8ba1\u91cc\u9762\u7684\u5b57\u7b26\u9891\u7387\u5c31\u884c\u3002<br \/>\n\u4ee3\u7801\uff1a<\/p>\n<pre class=\"lang:c++ decode:true \">class Solution {\npublic:\n    bool isAnagram(string s, string t) {\n        if(s.size() != t.size())\n            return false;\n        int stable[26] = {0};\n        int ttable[26] = {0};\n        for(int i=0; i&lt;s.size(); i++){\n            stable[s[i] - 'a'] ++;\n            ttable[t[i] - 'a'] ++;\n        }\n        for(int i=0; i&lt;26; i++){\n            if (stable[i] != ttable[i])\n                return false;\n        }\n        return true;\n    }\n};<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u9898\uff1ahttps:\/\/leetcode.com\/problems\/valid-anagram\/ \u601d\u8def\uff1aAnagram\u5c31\u662f\u6307\u4e24\u4e2a\u5355\u8bcd\uff08\u4e00\u8bf4\u53e5\u5b50\u4e5f\u884c\uff09\u91cc\u9762\u5b57\u7b26\u7684\u79cd\u7c7b\u3001\u6570\u91cf\u4e00\u6837\uff0c\u4f46\u662f\u80fd\u62fc\u51fa\u4e0d\u540c\u7684\u8bcd\u3002\u6240\u4ee5\u601d\u8def\u5c31\u662f\u7edf\u8ba1\u91cc\u9762\u7684\u5b57\u7b26\u9891\u7387\u5c31\u884c\u3002 \u4ee3\u7801\uff1a class Solution { public: bool isAnagram(string s, string t) { if(s.size() != t.size()) return false; int stable[26] = {0}; int ttable[26] = {0}; for(int i=0; i&lt;s.size(); i++){ stable[s[i] &#8211; &#8216;a&#8217;] ++; ttable[t[i] &#8211; &#8216;a&#8217;] ++; } for(int i=0; i&lt;26; i++){ if (stable[i] != ttable[i]) return false; } return true; } }; &nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[66],"class_list":["post-1839","post","type-post","status-publish","format-standard","hentry","category-study","tag-leetcode-oj"],"_links":{"self":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1839"}],"version-history":[{"count":0,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1839\/revisions"}],"wp:attachment":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}