{"id":167442,"date":"2020-10-14T18:48:18","date_gmt":"2020-10-14T10:48:18","guid":{"rendered":"http:\/\/4563.org\/?p=167442"},"modified":"2020-10-15T16:23:01","modified_gmt":"2020-10-15T08:23:01","slug":"facebook-%e9%9d%a2%e8%af%95%e9%a2%98%ef%bc%9a%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%ef%bc%88dfs%ef%bc%89","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=167442","title":{"rendered":"Facebook \u9762\u8bd5\u9898\uff1a\u7535\u8bdd\u53f7\u7801\u7684\u5b57\u6bcd\u7ec4\u5408\uff08DFS\uff09"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Facebook \u9762\u8bd5\u9898\uff1a\u7535\u8bdd\u53f7\u7801\u7684\u5b57\u6bcd\u7ec4\u5408\uff08DFS\uff09               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zzzrf <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u7ed9\u4e00\u4e2a\u4e0d\u5305\u542b 0 \u548c 1 \u7684\u6570\u5b57\u5b57\u7b26\u4e32\uff0c\u6bcf\u4e2a\u6570\u5b57\u4ee3\u8868\u4e00\u4e2a\u5b57\u6bcd\uff0c\u8bf7\u8fd4\u56de\u5176\u6240\u6709\u53ef\u80fd\u7684\u5b57\u6bcd\u7ec4\u5408\u3002 \u4e0b\u56fe\u7684\u624b\u673a\u6309\u952e\u56fe\uff0c\u5c31\u8868\u793a\u4e86\u6bcf\u4e2a\u6570\u5b57\u53ef\u4ee5\u4ee3\u8868\u7684\u5b57\u6bcd\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/10\/20201013092242982.pngpic_center.png\" alt=\"Facebook \u9762\u8bd5\u9898\uff1a\u7535\u8bdd\u53f7\u7801\u7684\u5b57\u6bcd\u7ec4\u5408\uff08DFS\uff09\" \/><\/p>\n<ul>\n<li>\u4ee5\u4e0a\u7684\u7b54\u6848\u662f\u6309\u7167\u8bcd\u5178\u7f16\u64b0\u987a\u5e8f\u8fdb\u884c\u8f93\u51fa\u7684\uff0c\u4e0d\u8fc7\uff0c\u5728\u505a\u672c\u9898\u65f6\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4efb\u610f\u9009\u62e9\u4f60\u559c\u6b22\u7684\u8f93\u51fa\u987a\u5e8f\u3002<\/li>\n<\/ul>\n<p>\u70b9\u6b64\u505a\u9898<\/p>\n<h2>\u6837\u4f8b 1:<\/h2>\n<pre><code>\u8f93\u5165: \"23\" \u8f93\u51fa: [\"ad\", \"ae\", \"af\", \"bd\", \"be\", \"bf\", \"cd\", \"ce\", \"cf\"] \u89e3\u91ca:  '2' \u53ef\u4ee5\u662f 'a', 'b' \u6216 'c' '3' \u53ef\u4ee5\u662f 'd', 'e' \u6216 'f' <\/code><\/pre>\n<h2>\u6837\u4f8b 2:<\/h2>\n<pre><code>\u8f93\u5165: \"5\" \u8f93\u51fa: [\"j\", \"k\", \"l\"] <\/code><\/pre>\n<h2>\u7b97\u6cd5\uff1aDFS<\/h2>\n<ol>\n<li>\u5982\u679c\u8f93\u5165\u7684\u6570\u5b57\u4e32\u4e3a\u7a7a\uff0c\u8fd4\u56de\u7a7a\u5217\u8868\uff1b<\/li>\n<li>\u9884\u5904\u7406\u5b58\u50a8 1-9 \u5404\u4e2a\u6570\u5b57\u53ef\u4ee5\u5bf9\u5e94\u7684\u5b57\u6bcd\uff1b<\/li>\n<li>\u5bf9\u6570\u5b57\u4e32\u8fdb\u884c\u6df1\u5ea6\u4f18\u5148\u641c\u7d22\uff0c\u4f20\u5165\u7684\u53c2\u6570\u5305\u62ec\uff1a\u6570\u5b57\u4e32 digits \u3001\u5f53\u524d\u7684\u4f4d\u7f6e index \u3001\u5f53\u524d\u5b58\u5165\u7684\u5b57\u7b26\u4e32 current \u3001\u4fdd\u5b58\u7b54\u6848\u7684\u5b57\u7b26\u4e32\u5217\u8868 result \u3001\u6570\u5b57\u5b57\u6bcd\u6620\u5c04\u7684\u5b57\u7b26\u4e32\u6570\u7ec4 phone \uff1b<\/li>\n<\/ol>\n<ul>\n<li>\u5f53\u524d\u4f4d\u7f6e\u8fbe\u5230\u6570\u5b57\u4e32\u672b\u5c3e\u5373\u8fbe\u5230\u8fb9\u754c\uff0c\u5c06 current \u6dfb\u52a0\u5230 result\uff0c\u56de\u6eaf\uff1b<\/li>\n<li>\u5bf9 index \u4f4d\u7f6e\u7684\u6570\u5b57\u901a\u8fc7 phone \u627e\u51fa\u53ef\u4ee5\u9009\u7528\u7684\u6bcf\u4e2a\u5b57\u6bcd\uff0c\u5206\u522b\u9012\u5f52\u8c03\u7528 dfs \uff1b<\/li>\n<li>\u9012\u5f52\u6b65\u8fdb\u4e3a\uff1aindex+1\uff0ccurrent+\u9009\u7528\u7684\u5b57\u6bcd\uff1b<\/li>\n<\/ul>\n<h2>\u590d\u6742\u5ea6\u5206\u6790<\/h2>\n<ul>\n<li>\u65f6\u95f4\u590d\u6742\u5ea6\uff1aO(4^n), n \u4e3a\u6570\u5b57\u4e32\u957f\u5ea6\n<ul>\n<li>\u6bcf\u4e2a\u6570\u5b57\u90fd\u6709 3-4 \u4e2a\u53ef\u5bf9\u5e94\u7684\u5b57\u6bcd<\/li>\n<\/ul>\n<\/li>\n<li>\u7a7a\u95f4\u590d\u6742\u5ea6\uff1aO(4^n),n \u4e3a\u6570\u5b57\u4e32\u957f\u5ea6\n<ul>\n<li>\u5bf9\u4e8e\u7528\u6765\u4fdd\u5b58\u7b54\u6848\u7684\u5217\u8868\uff0c\u6700\u591a\u6709 4^n \u79cd\u7ec4\u5408<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><code>public class Solution {     \/**      * @param digits: A digital string      * @return: all posible letter combinations      *\/      public static final HashMap&lt;Integer, String&gt; PHONE = new HashMap&lt;Integer, String&gt;() {         {             put(0, \"\"); put(1, \"\"); put(2, \"abc\"); put(3, \"def\"); put(4, \"ghi\");              put(5, \"jkl\"); put(6, \"mno\"); put(7, \"pqrs\"); put(8, \"tuv\"); put(9, \"wxyz\");          }     };      public List&lt;String&gt; letterCombinations(String digits) {         List&lt;String&gt; result = new ArrayList&lt;&gt;();         if (digits.length() == 0) {             return result;         }         dfs(0, \"\", digits, PHONE, result);         return result;     }      private void dfs(int index, String current, String digits, HashMap&lt;Integer, String&gt; PHONE, List&lt;String&gt; result) {         if (index == digits.length()) {             result.add(current);             return;         }          int d = digits.charAt(index) - '0';         for (char c : PHONE.get(d).toCharArray()) {             dfs(index + 1, current + c, digits, PHONE, result);         }     } } <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>0<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Facebook \u9762\u8bd5\u9898\uff1a\u7535\u8bdd\u53f7\u7801&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/167442"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=167442"}],"version-history":[{"count":1,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/167442\/revisions"}],"predecessor-version":[{"id":167444,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/167442\/revisions\/167444"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=167442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=167442"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=167442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}