{"id":1897,"date":"2022-01-12T16:58:19","date_gmt":"2022-01-12T08:58:19","guid":{"rendered":"http:\/\/139.9.1.231\/?p=1897"},"modified":"2022-01-12T16:58:40","modified_gmt":"2022-01-12T08:58:40","slug":"leetcodeday17","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/12\/leetcodeday17\/","title":{"rendered":"leetcodeday17 \u7535\u8bdd\u53f7\u7801\u7684\u5b57\u6bcd\u7ec4\u5408"},"content":{"rendered":"\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u4ec5\u5305\u542b\u6570\u5b57&nbsp;2-9&nbsp;\u7684\u5b57\u7b26\u4e32\uff0c\u8fd4\u56de\u6240\u6709\u5b83\u80fd\u8868\u793a\u7684\u5b57\u6bcd\u7ec4\u5408\u3002\u7b54\u6848\u53ef\u4ee5\u6309 \u4efb\u610f\u987a\u5e8f \u8fd4\u56de\u3002<\/p>\n\n\n\n<p>\u7ed9\u51fa\u6570\u5b57\u5230\u5b57\u6bcd\u7684\u6620\u5c04\u5982\u4e0b\uff08\u4e0e\u7535\u8bdd\u6309\u952e\u76f8\u540c\uff09\u3002\u6ce8\u610f 1 \u4e0d\u5bf9\u5e94\u4efb\u4f55\u5b57\u6bcd\u3002<\/p>\n\n\n\n<div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" width=\"199\" height=\"157\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-197.png\" alt=\"\" class=\"wp-image-1898\"\/><\/figure><\/div>\n\n\n\n<p>\u793a\u4f8b 1\uff1a<\/p>\n\n\n\n<p>\u8f93\u5165\uff1adigits = &#8220;23&#8221;<br>\u8f93\u51fa\uff1a[&#8220;ad&#8221;,&#8221;ae&#8221;,&#8221;af&#8221;,&#8221;bd&#8221;,&#8221;be&#8221;,&#8221;bf&#8221;,&#8221;cd&#8221;,&#8221;ce&#8221;,&#8221;cf&#8221;]<br>\u793a\u4f8b 2\uff1a<\/p>\n\n\n\n<p>\u8f93\u5165\uff1adigits = &#8220;&#8221;<br>\u8f93\u51fa\uff1a[]<br>\u793a\u4f8b 3\uff1a<\/p>\n\n\n\n<p>\u8f93\u5165\uff1adigits = &#8220;2&#8221;<br>\u8f93\u51fa\uff1a[&#8220;a&#8221;,&#8221;b&#8221;,&#8221;c&#8221;]<\/p>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul><li><code>0 &lt;= digits.length &lt;= 4<\/code><\/li><li><code>digits[i]<\/code>&nbsp;\u662f\u8303\u56f4&nbsp;<code>['2', '9']<\/code>&nbsp;\u7684\u4e00\u4e2a\u6570\u5b57<\/li><\/ul>\n\n\n\n<p>\u601d\u8def\uff1a\u904d\u5386\u9012\u5f52\u6c42\u89e3<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># @lc code=start\r\nclass Solution:\r\n    def letterCombinations(self, digits: str) -> List&#91;str]:\r\n        if digits==\"\": \r\n            return &#91;]\r\n        n=len(digits)\r\n        sets={\"2\":&#91;\"a\",\"b\",\"c\"],\"3\":&#91;\"d\",\"e\",\"f\"],\"4\":&#91;\"g\",\"h\",\"i\"],\"5\":&#91;\"j\",\"k\",\"l\"],\"6\":&#91;\"m\",\"n\",\"o\"],\"7\":&#91;\"p\",\"q\",\"r\",\"s\"],\"8\":&#91;\"t\",\"u\",\"v\"],\"9\":&#91;\"w\",\"x\",\"y\",\"z\"]}\r\n        def upsort(strs): \r\n            if len(strs)==1: \r\n                return sets&#91;strs]\r\n    \r\n            result = upsort(strs&#91;:-1])\r\n            rev=&#91;]\r\n            for i in range(len(result)):\r\n                 for j in sets&#91;strs&#91;-1]]:\r\n                    rev.append(result&#91;i]+j)\r\n            return rev\r\n        return upsort(digits)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"925\" height=\"174\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-198.png\" alt=\"\" class=\"wp-image-1902\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-198.png 925w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-198-300x56.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-198-768x144.png 768w\" sizes=\"(max-width: 925px) 100vw, 925px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u5b9a\u4e00\u4e2a\u4ec5\u5305\u542b\u6570\u5b57&nbsp;2-9&nbsp;\u7684\u5b57\u7b26\u4e32\uff0c\u8fd4\u56de\u6240\u6709\u5b83\u80fd\u8868\u793a\u7684\u5b57\u6bcd\u7ec4\u5408\u3002\u7b54\u6848\u53ef\u4ee5\u6309 \u4efb\u610f\u987a\u5e8f \u8fd4 &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/12\/leetcodeday17\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday17 \u7535\u8bdd\u53f7\u7801\u7684\u5b57\u6bcd\u7ec4\u5408<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/1897"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=1897"}],"version-history":[{"count":5,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/1897\/revisions"}],"predecessor-version":[{"id":1904,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/1897\/revisions\/1904"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=1897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=1897"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=1897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}