{"id":39,"date":"2021-10-28T13:14:12","date_gmt":"2021-10-28T05:14:12","guid":{"rendered":"https:\/\/dcupqiu.club\/?p=39"},"modified":"2022-02-20T19:16:26","modified_gmt":"2022-02-20T11:16:26","slug":"reordered-power-of-2","status":"publish","type":"post","link":"https:\/\/dcupqiu.club\/?p=39","title":{"rendered":"Reordered Power of 2"},"content":{"rendered":"<p>\u8bb0\u5f552\u7684\u5e42\u7684\u6570\u5b57\u5305\u542b\u7684\u5404\u6570\u5b57\u51fa\u73b0\u6b21\u6570\uff0c\u8bb0\u5f55\u4e3aunordered map\uff0c\u67e5\u8868<\/p>\n<p><!--kg-card-begin: markdown--><\/p>\n<pre><code>string countDigits(int n) {    string cnt(10, 0);\n    while (n) {\n        ++cnt[n % 10];\n        n \/= 10;\n    }\n    return cnt;\n}\nunordered_set&lt;string&gt; powerOf2Digits;\nint init = []() {\n    for (int n = 1; n &lt;= 1e9; n &lt;&lt;= 1) {\n        powerOf2Digits.insert(countDigits(n));\n    }\n    return 0;\n}();\nclass Solution {\npublic:\n    bool reorderedPowerOf2(int n) {\n        return powerOf2Digits.count(countDigits(n));\n    }\n};\n<\/code><\/pre>\n<p><!--kg-card-end: markdown--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8bb0\u5f552\u7684\u5e42\u7684\u6570\u5b57\u5305\u542b\u7684\u5404\u6570\u5b57\u51fa\u73b0\u6b21\u6570\uff0c\u8bb0\u5f55\u4e3auno&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[5],"class_list":["post-39","post","type-post","status-publish","format-standard","hentry","category-leetcode","tag-leetcode"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.5.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Reordered Power of 2 - \u79cb\u5586\u306eSite<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dcupqiu.club\/?p=39\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Reordered Power of 2 - \u79cb\u5586\u306eSite\" \/>\n<meta property=\"og:description\" content=\"\u8bb0\u5f552\u7684\u5e42\u7684\u6570\u5b57\u5305\u542b\u7684\u5404\u6570\u5b57\u51fa\u73b0\u6b21\u6570\uff0c\u8bb0\u5f55\u4e3auno...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dcupqiu.club\/?p=39\" \/>\n<meta property=\"og:site_name\" content=\"\u79cb\u5586\u306eSite\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-28T05:14:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-20T11:16:26+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u79cb\u5586\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dcupqiu.club\/#website\",\"url\":\"https:\/\/dcupqiu.club\/\",\"name\":\"\u79cb\u5586\u306eSite\",\"description\":\"WwwwwW\",\"publisher\":{\"@id\":\"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dcupqiu.club\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dcupqiu.club\/?p=39#webpage\",\"url\":\"https:\/\/dcupqiu.club\/?p=39\",\"name\":\"Reordered Power of 2 - \u79cb\u5586\u306eSite\",\"isPartOf\":{\"@id\":\"https:\/\/dcupqiu.club\/#website\"},\"datePublished\":\"2021-10-28T05:14:12+00:00\",\"dateModified\":\"2022-02-20T11:16:26+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dcupqiu.club\/?p=39#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dcupqiu.club\/?p=39\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dcupqiu.club\/?p=39#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/dcupqiu.club\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Reordered Power of 2\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/dcupqiu.club\/?p=39#article\",\"isPartOf\":{\"@id\":\"https:\/\/dcupqiu.club\/?p=39#webpage\"},\"author\":{\"@id\":\"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20\"},\"headline\":\"Reordered Power of 2\",\"datePublished\":\"2021-10-28T05:14:12+00:00\",\"dateModified\":\"2022-02-20T11:16:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dcupqiu.club\/?p=39#webpage\"},\"wordCount\":5,\"publisher\":{\"@id\":\"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20\"},\"keywords\":[\"Leetcode\"],\"articleSection\":[\"Leetcode\"],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20\",\"name\":\"\u79cb\u5586\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/dcupqiu.club\/#personlogo\",\"inLanguage\":\"zh-Hans\",\"url\":\"https:\/\/dcupqiu.club\/wp-content\/uploads\/\/2022\/04\/ww.png\",\"contentUrl\":\"https:\/\/dcupqiu.club\/wp-content\/uploads\/\/2022\/04\/ww.png\",\"width\":920,\"height\":700,\"caption\":\"\u79cb\u5586\"},\"logo\":{\"@id\":\"https:\/\/dcupqiu.club\/#personlogo\"},\"sameAs\":[\"http:\/\/dcupqiu.club\"],\"url\":\"https:\/\/dcupqiu.club\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Reordered Power of 2 - \u79cb\u5586\u306eSite","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dcupqiu.club\/?p=39","og_locale":"zh_CN","og_type":"article","og_title":"Reordered Power of 2 - \u79cb\u5586\u306eSite","og_description":"\u8bb0\u5f552\u7684\u5e42\u7684\u6570\u5b57\u5305\u542b\u7684\u5404\u6570\u5b57\u51fa\u73b0\u6b21\u6570\uff0c\u8bb0\u5f55\u4e3auno...","og_url":"https:\/\/dcupqiu.club\/?p=39","og_site_name":"\u79cb\u5586\u306eSite","article_published_time":"2021-10-28T05:14:12+00:00","article_modified_time":"2022-02-20T11:16:26+00:00","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u79cb\u5586"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/dcupqiu.club\/#website","url":"https:\/\/dcupqiu.club\/","name":"\u79cb\u5586\u306eSite","description":"WwwwwW","publisher":{"@id":"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dcupqiu.club\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"WebPage","@id":"https:\/\/dcupqiu.club\/?p=39#webpage","url":"https:\/\/dcupqiu.club\/?p=39","name":"Reordered Power of 2 - \u79cb\u5586\u306eSite","isPartOf":{"@id":"https:\/\/dcupqiu.club\/#website"},"datePublished":"2021-10-28T05:14:12+00:00","dateModified":"2022-02-20T11:16:26+00:00","breadcrumb":{"@id":"https:\/\/dcupqiu.club\/?p=39#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dcupqiu.club\/?p=39"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/dcupqiu.club\/?p=39#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/dcupqiu.club\/"},{"@type":"ListItem","position":2,"name":"Reordered Power of 2"}]},{"@type":"Article","@id":"https:\/\/dcupqiu.club\/?p=39#article","isPartOf":{"@id":"https:\/\/dcupqiu.club\/?p=39#webpage"},"author":{"@id":"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20"},"headline":"Reordered Power of 2","datePublished":"2021-10-28T05:14:12+00:00","dateModified":"2022-02-20T11:16:26+00:00","mainEntityOfPage":{"@id":"https:\/\/dcupqiu.club\/?p=39#webpage"},"wordCount":5,"publisher":{"@id":"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20"},"keywords":["Leetcode"],"articleSection":["Leetcode"],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/dcupqiu.club\/#\/schema\/person\/33f847360b49873a92e0a1461d4d6a20","name":"\u79cb\u5586","image":{"@type":"ImageObject","@id":"https:\/\/dcupqiu.club\/#personlogo","inLanguage":"zh-Hans","url":"https:\/\/dcupqiu.club\/wp-content\/uploads\/\/2022\/04\/ww.png","contentUrl":"https:\/\/dcupqiu.club\/wp-content\/uploads\/\/2022\/04\/ww.png","width":920,"height":700,"caption":"\u79cb\u5586"},"logo":{"@id":"https:\/\/dcupqiu.club\/#personlogo"},"sameAs":["http:\/\/dcupqiu.club"],"url":"https:\/\/dcupqiu.club\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/dcupqiu.club\/index.php?rest_route=\/wp\/v2\/posts\/39","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dcupqiu.club\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dcupqiu.club\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dcupqiu.club\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dcupqiu.club\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=39"}],"version-history":[{"count":1,"href":"https:\/\/dcupqiu.club\/index.php?rest_route=\/wp\/v2\/posts\/39\/revisions"}],"predecessor-version":[{"id":71,"href":"https:\/\/dcupqiu.club\/index.php?rest_route=\/wp\/v2\/posts\/39\/revisions\/71"}],"wp:attachment":[{"href":"https:\/\/dcupqiu.club\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dcupqiu.club\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dcupqiu.club\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}