{"id":2230,"date":"2022-01-21T17:00:08","date_gmt":"2022-01-21T09:00:08","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2230"},"modified":"2022-01-21T17:00:10","modified_gmt":"2022-01-21T09:00:10","slug":"leetcodeday46","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/21\/leetcodeday46\/","title":{"rendered":"leetcodeday46 &#8211;\u5168\u6392\u5217"},"content":{"rendered":"\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u4e0d\u542b\u91cd\u590d\u6570\u5b57\u7684\u6570\u7ec4&nbsp;<code>nums<\/code>&nbsp;\uff0c\u8fd4\u56de\u5176&nbsp;<strong>\u6240\u6709\u53ef\u80fd\u7684\u5168\u6392\u5217<\/strong>&nbsp;\u3002\u4f60\u53ef\u4ee5&nbsp;<strong>\u6309\u4efb\u610f\u987a\u5e8f<\/strong>&nbsp;\u8fd4\u56de\u7b54\u6848\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>nums = &#91;1,2,3]\n<strong>\u8f93\u51fa\uff1a<\/strong>&#91;&#91;1,2,3],&#91;1,3,2],&#91;2,1,3],&#91;2,3,1],&#91;3,1,2],&#91;3,2,1]]<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>nums = &#91;0,1]\n<strong>\u8f93\u51fa\uff1a<\/strong>&#91;&#91;0,1],&#91;1,0]]<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 3\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>nums = &#91;1]\n<strong>\u8f93\u51fa\uff1a<\/strong>&#91;&#91;1]]<\/code><\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul><li><code>1 &lt;= nums.length &lt;= 6<\/code><\/li><li><code>-10 &lt;= nums[i] &lt;= 10<\/code><\/li><li><code>nums<\/code>\u00a0\u4e2d\u7684\u6240\u6709\u6574\u6570\u00a0<strong>\u4e92\u4e0d\u76f8\u540c<\/strong><\/li><\/ul>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u66b4\u529b\u6c42\u89e3\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># &#91;46] \u5168\u6392\u5217\r\n#\r\n\r\n# @lc code=start\r\nclass Solution:\r\n    def permute(self, nums: List&#91;int]) -> List&#91;List&#91;int]]:\r\n        import copy\r\n        def subpermute(nums,index):\r\n            if index==0:\r\n               return &#91;&#91;nums&#91;0]]]\r\n            else:\r\n                rev=subpermute(nums,index-1)\r\n                res=list()\r\n                for i in range(len(rev)):\r\n                    #print(rev&#91;i])\r\n                    for j in range(len(rev&#91;i])+1):\r\n    \r\n                        mid=copy.deepcopy(rev&#91;i])\r\n                        #print(mid)\r\n                        mid.insert(j,nums&#91;index])\r\n                        res.append(mid)\r\n                        \r\n                return res\r\n        index=len(nums)-1\r\n        return subpermute(nums,index)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"742\" height=\"215\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-258.png\" alt=\"\" class=\"wp-image-2231\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-258.png 742w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-258-300x87.png 300w\" sizes=\"(max-width: 742px) 100vw, 742px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u5b9a\u4e00\u4e2a\u4e0d\u542b\u91cd\u590d\u6570\u5b57\u7684\u6570\u7ec4&nbsp;nums&nbsp;\uff0c\u8fd4\u56de\u5176&nbsp;\u6240\u6709\u53ef\u80fd\u7684\u5168\u6392\u5217&nbsp;\u3002\u4f60 &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/21\/leetcodeday46\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday46 &#8211;\u5168\u6392\u5217<\/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\/2230"}],"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=2230"}],"version-history":[{"count":3,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2230\/revisions"}],"predecessor-version":[{"id":2234,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2230\/revisions\/2234"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2230"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}