{"id":2796,"date":"2020-01-19T13:22:21","date_gmt":"2020-01-19T05:22:21","guid":{"rendered":"http:\/\/www.sniper97.cn\/?p=2796"},"modified":"2020-01-19T13:22:21","modified_gmt":"2020-01-19T05:22:21","slug":"%e3%80%90leetcode%e3%80%910017-%e7%94%b5%e8%af%9d%e5%8f%b7%e7%a0%81%e7%9a%84%e5%ad%97%e6%af%8d%e7%bb%84%e5%90%88","status":"publish","type":"post","link":"http:\/\/www.sniper97.cn\/index.php\/note\/algorithm\/2796\/","title":{"rendered":"\u3010LeetCode\u30110017 \u7535\u8bdd\u53f7\u7801\u7684\u5b57\u6bcd\u7ec4\u5408"},"content":{"rendered":"\n<p><a href=\"https:\/\/leetcode-cn.com\/problems\/letter-combinations-of-a-phone-number\/\">https:\/\/leetcode-cn.com\/problems\/letter-combinations-of-a-phone-number\/<\/a><\/p>\n\n\n<pre class=\"wp-block-preformatted\"># -*- coding:utf-8 -*-\n<em>\n<\/em>class Solution(object):\n    def letterCombinations(self, digits):\n        <em>\"\"\"\n        <\/em><strong><em>:type<\/em><\/strong><em> digits: str\n        <\/em><strong><em>:rtype<\/em><\/strong><em>: List[str]\n        \"\"\"\n        <\/em>KEY = {'2': ['a', 'b', 'c'],\n               '3': ['d', 'e', 'f'],\n               '4': ['g', 'h', 'i'],\n               '5': ['j', 'k', 'l'],\n               '6': ['m', 'n', 'o'],\n               '7': ['p', 'q', 'r', 's'],\n               '8': ['t', 'u', 'v'],\n               '9': ['w', 'x', 'y', 'z']}\n        if digits == '':\n            return\n        res = ['']\n        for each in digits:\n            res = [pre + sub for pre in res for sub in KEY[each]]\n        return res\nif __name__ == '__main__':\n    digit = '23'\n    print(Solution().letterCombinations(digit))\n<\/pre>\n\n\n<p><strong>\u601d\u8def<\/strong>\uff1a\u8fd9\u9053\u9898\u4e0d\u662f\u5f88\u96be\uff0c\u503c\u5f97\u4e00\u63d0\u7684\u5c31\u662f\u8fd9\u4e2a\u8bed\u53e5\u5d4c\u5957\uff0c\u4e0d\u5f97\u4e0d\u8bf4python\u8fd8\u662f\u65b9\u4fbf\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/leetcode-cn.com\/problems\/letter-combinatio [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[10],"tags":[],"views":1776,"_links":{"self":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/2796"}],"collection":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2796"}],"version-history":[{"count":0,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/2796\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2796"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}