{"id":188709,"date":"2020-11-10T08:36:18","date_gmt":"2020-11-10T00:36:18","guid":{"rendered":"http:\/\/4563.org\/?p=188709"},"modified":"2020-11-10T08:36:18","modified_gmt":"2020-11-10T00:36:18","slug":"%e6%9c%89%e9%81%93%e9%a2%98%e6%b1%82%e8%80%81%e5%93%a5%e4%bb%ac%e8%a7%a3%e7%ad%94%ef%bc%8c%e4%b8%8d%e7%9f%a5%e9%81%93%e9%94%99%e5%9c%a8%e5%93%aa%e4%ba%86%e3%80%82","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=188709","title":{"rendered":"\u6709\u9053\u9898\u6c42\u8001\u54e5\u4eec\u89e3\u7b54\uff0c\u4e0d\u77e5\u9053\u9519\u5728\u54ea\u4e86\u3002"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6709\u9053\u9898\u6c42\u8001\u54e5\u4eec\u89e3\u7b54\uff0c\u4e0d\u77e5\u9053\u9519\u5728\u54ea\u4e86\u3002               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zzzrf <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u7ed9\u4e00\u4e2a\u5b57\u7b26\u4e32,\u4f60\u53ef\u4ee5\u9009\u62e9\u5728\u4e00\u4e2a\u5b57\u7b26\u6216\u4e24\u4e2a\u76f8\u90bb\u5b57\u7b26\u4e4b\u540e\u62c6\u5206\u5b57\u7b26\u4e32,\u4f7f\u5b57\u7b26\u4e32\u7531\u4ec5\u4e00\u4e2a\u5b57\u7b26\u6216\u4e24\u4e2a\u5b57\u7b26\u7ec4\u6210,\u8f93\u51fa\u6240\u6709\u53ef\u80fd\u7684\u7ed3\u679c\u3002<\/p>\n<p>\u9898\u76ee\u94fe\u63a5<\/p>\n<h2>\u6837\u4f8b 1<\/h2>\n<pre><code>\u8f93\u5165\uff1a \"123\" \u8f93\u51fa\uff1a [[\"1\",\"2\",\"3\"],[\"12\",\"3\"],[\"1\",\"23\"]] <\/code><\/pre>\n<h2>\u6837\u4f8b 2<\/h2>\n<pre><code>\u8f93\u5165\uff1a \"12345\" \u8f93\u51fa\uff1a [[\"1\",\"23\",\"45\"],[\"12\",\"3\",\"45\"],[\"12\",\"34\",\"5\"],[\"1\",\"2\",\"3\",\"45\"],[\"1\",\"2\",\"34\",\"5\"],[\"1\",\"23\",\"4\",\"5\"],[\"12\",\"3\",\"4\",\"5\"],[\"1\",\"2\",\"3\",\"4\",\"5\"]] <\/code><\/pre>\n<h2>\u8fd9\u662f\u6211\u7684\u89e3\u6cd5\uff0c\u60f3\u95ee\u4e0b\u5927\u5bb6\u9519\u5728\u54ea\u91cc\uff1a<\/h2>\n<pre><code>public class Solution { \/* * @param : a string to be split * @return: all possible split string array *\/ public List&lt;List&gt; splitString(String s) { List&lt;List&gt; result = new ArrayList&lt;&gt;();      dfs(s,0,new ArrayList&lt;String&gt;(),result);     return result;      }   private void dfs(String s, int index, List&lt;String&gt; cur, List&lt;List&lt;String&gt;&gt; result){          if ( index == s.length()){         result.add(new ArrayList&lt;String&gt;(cur));         return;     }          cur.add(String.valueOf(s.charAt(index)));     dfs(s,index+1,cur,result);     cur.remove(cur.size()-1);               if (index &lt; s.length()-1){         cur.add(s.substring(index,index+2));         dfs(s,index+2,cur,result);         cur.remove(cur.size()-1);                 }     } } <\/code><\/pre>\n<h1>\u5b98\u65b9\u89e3\u6cd5\u7ed9\u4e2a\u53c2\u8003\uff1a<\/h1>\n<p> <\/p>\n<h2>\u7b97\u6cd5\uff1aDFS<\/h2>\n<p>\u7531\u4e8e\u672c\u9898\u53ef\u4ee5\u9009\u62e9\u5728\u4e00\u4e2a\u5b57\u7b26\u6216\u4e24\u4e2a\u76f8\u90bb\u5b57\u7b26\u4e4b\u540e\u62c6\u5206\u5b57\u7b26\u4e32\uff0c\u4e14\u6700\u540e\u9700\u8f93\u51fa\u6240\u6709\u53ef\u80fd\u7684\u7ec4\u5408\uff0c\u5373\u6bcf\u6b21\u90fd\u9700\u8981\u628a\u6574\u4e2a\u5b57\u7b26\u4e32\u6309\u7167\u7279\u5b9a\u8981\u6c42\u5207\u5206\u5b8c\u6bd5\uff0c\u53ef\u4ee5\u60f3\u5230\u5229\u7528\u9012\u5f52 dfs \u6765\u5b8c\u6210\uff1b<\/p>\n<h2>\u7b97\u6cd5\u6b65\u9aa4<\/h2>\n<p>\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u6df1\u5ea6\u4f18\u5148\u641c\u7d22\uff0c\u5f53\u524d\u4f4d\u7f6e\u8fbe\u5230\u5b57\u7b26\u4e32\u672b\u5c3e\u4f5c\u4e3a\u8fb9\u754c\u3002\u641c\u7d22\u65f6\u6709\u4e24\u79cd\u60c5\u51b5\uff1a<\/p>\n<ol>\n<li>\u5207\u5272\u5f53\u524d\u7684 1 \u4e2a\u5b57\u7b26\uff1a<\/li>\n<\/ol>\n<ul>\n<li>\u5c06\u8fd9 1 \u4e2a\u5b57\u7b26\u5355\u72ec\u4f5c\u4e3a\u5b57\u7b26\u4e32\u5b58\u5165\u5217\u8868<\/li>\n<li>\u5f53\u524d\u4f4d\u7f6e\u6b65\u8fdb 1<\/li>\n<\/ul>\n<ol>\n<li>\u5207\u5272\u5f53\u524d\u7684\u8fde\u7eed 2 \u4e2a\u5b57\u7b26\uff08\u9700\u6ee1\u8db3\u5f53\u524d\u4f4d\u7f6e\u4e0d\u662f\u5b57\u7b26\u4e32\u672b\u5c3e\uff09\uff1a<\/li>\n<\/ol>\n<ul>\n<li>\u5c06\u8fde\u7eed 2 \u4e2a\u5b57\u7b26\u4fdd\u5b58\u4e3a\u5b57\u7b26\u4e32\u5b58\u5165\u5217\u8868<\/li>\n<li>\u5f53\u524d\u4f4d\u7f6e\u6b65\u8fdb 2<\/li>\n<\/ul>\n<h2>\u590d\u6742\u5ea6\u5206\u6790<\/h2>\n<ul>\n<li>\u65f6\u95f4\u590d\u6742\u5ea6\uff1aO(2^n), n \u4e3a\u5b57\u7b26\u4e32\u957f\u5ea6\n<ul>\n<li>\u9664\u4e86\u5b57\u7b26\u4e32\u6700\u540e\u4e00\u4f4d\uff0c\u5176\u4ed6\u4f4d\u7f6e\u90fd\u6709\u4e24\u79cd\u5207\u5272\u65b9\u5f0f<\/li>\n<\/ul>\n<\/li>\n<li>\u7a7a\u95f4\u590d\u6742\u5ea6\uff1aO(2^n^2),n \u4e3a\u5b57\u7b26\u4e32\u957f\u5ea6\n<ul>\n<li>\u5b58\u50a8\u6240\u6709\u60c5\u51b5\u9700\u8981\u6240\u6709\u5207\u5206\u65b9\u5f0f*n \u7684\u7a7a\u95f4<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><code>public class Solution {     \/*      * @param : a string to be split      * @return: all possible split string array      *\/     public List&lt;List&lt;String&gt;&gt; splitString(String s) {         List&lt;List&lt;String&gt;&gt; result = new ArrayList&lt;&gt;();         dfs(s, 0, new ArrayList&lt;&gt;(), result);         return result;     }      private void dfs(String s, int index, List&lt;String&gt; current, List&lt;List&lt;String&gt;&gt; result) {         if (index == s.length()) {             result.add(new ArrayList&lt;&gt;(current));             return;         }         \/\/ \u5206\u5272 1 \u4e2a\u5b57\u7b26         current.add(String.valueOf(s.charAt(index)));         dfs(s, index + 1, current, result);         current.remove(current.size() - 1);         \/\/ \u5206\u5272 2 \u4e2a\u5b57\u7b26         if (index &lt; s.length() - 1) {             current.add(s.substring(index, index + 2));             dfs(s, index + 2, current, result);             current.remove(current.size() - 1);         }     } } <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4025534\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : targetFree <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u903b\u8f91\u6ca1\u9519\uff0cJava \u8bed\u6cd5\u4e0d\u8fc7\u5173\uff0c\u8fd9\u662f\u4ec0\u4e48\u9b3c List&lt;List&gt; result\uff0c\u8865\u8865\u57fa\u7840\u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4025535\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhuyichen1017 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Java \u5c0f\u767d\uff0c\u4e0d\u660e\u767d\u4e00\u8bf4\u7684 List&lt;List&lt;String&gt;&gt; result \u6709\u4ec0\u4e48\u95ee\u9898\uff0c\u671b\u4e0b\u89e3\u7b54\u4e0b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4025536\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ResidualSoils <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Java \u770b\u7740\u597d\u607c\u706b\uff0c\u6362\u4e2a\u8bed\u8a00\u505a\u9898\u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4025537\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zzzrf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ResidualSoils \u53ea\u5b66\u4e86 Java                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4025538\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xjx0524 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8f93\u5165\u662f\u7a7a\u5b57\u7b26\u4e32\u7684\u60c5\u51b5\uff0c\u8fd4\u56de\u5e94\u8be5\u662f\u7a7a\uff0c\u4f60\u8fd9\u4e2a\u903b\u8f91\u5e94\u8be5\u662f\u585e\u4e86\u4e00\u4e2a\u7a7a\u4e32\u8fdb\u53bb                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4025539\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xjx0524 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53e6\u5916 leetcode \u4e0d\u662f\u4f1a\u663e\u793a\u5177\u4f53\u54ea\u4e2a case \u9519\u4e86\u5417\uff0c\u62ff\u51fa\u6765\u8c03\u8bd5\u4e00\u4e0b\u5c31\u77e5\u9053\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4025540\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zzzrf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @xjx0524 \u597d\u50cf\u6709\u70b9\u7406\u89e3\u4e86\uff0c\u611f\u8c22\uff01                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4025541\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : targetFree <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zhuyichen1017 List&lt;List&lt;String&gt;&gt; \u6ca1\u95ee\u9898\uff0cList&lt;List&gt; \u6ca1\u6709\u58f0\u660e\u7c7b\u578b\uff0c\u5f53\u7136\u6709\u95ee\u9898                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u9053\u9898\u6c42\u8001\u54e5\u4eec\u89e3\u7b54\uff0c\u4e0d\u77e5\u9053\u9519\u5728\u54ea\u4e86&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\/188709"}],"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=188709"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/188709\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188709"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}